// Rh Capture public static SpeckleObject ToSpeckle(this PolylineCurve poly) { Polyline polyline; if (poly.TryGetPolyline(out polyline)) { if (polyline.Count == 2) { return(new SpeckleLine(polyline.ToFlatArray(), null, poly.UserDictionary.ToSpeckle(root: poly))); } var myPoly = new SpecklePolyline(polyline.ToFlatArray()); myPoly.Closed = polyline.IsClosed; if (myPoly.Closed) { myPoly.Value.RemoveRange(myPoly.Value.Count - 3, 3); } myPoly.Domain = poly.Domain.ToSpeckle(); myPoly.Properties = poly.UserDictionary.ToSpeckle(root: poly); myPoly.GenerateHash(); return(myPoly); } return(null); }
/// <summary> /// SpecklePolyline to DS Rectangle if closed , four points and sides parallel; /// DS Polygon if closed or DS Polycurve otherwise /// </summary> /// <param name="polyline"></param> /// <returns></returns> public static Curve ToNative(this SpecklePolyline polyline) { var points = polyline.Value.ToPoints(); var polycurve = PolyCurve.ByPoints(polyline.Value.ToPoints()); // If closed and planar, make polygon if (polyline.Closed && polycurve.IsPlanar) { polycurve.Dispose(); // geometry not needed. Freeing memory. double dot = Vector.ByTwoPoints(points[0], points[1]).Dot(Vector.ByTwoPoints(points[1], points[2])); if (points.Count() == 4 && Threshold(dot, 0)) { return(Rectangle.ByCornerPoints(points).SetSpeckleProperties <Rectangle>(polyline.Properties)); } else { return(Polygon.ByPoints(polyline.Value.ToPoints()).SetSpeckleProperties <Polygon>(polyline.Properties)); } } else { return(polycurve.SetSpeckleProperties <PolyCurve>(polyline.Properties)); } }
// Deserialise public static PolylineCurve ToNative(this SpecklePolyline poly) { var myPoly = new PolylineCurve(poly.Value.ToPoints()); myPoly.UserDictionary.ReplaceContentsWith(poly.Properties.ToNative()); return(myPoly); }
public static SpecklePolyline ToSpecklePolyline(this PolylinePayload payload) { var line = new SpecklePolyline(payload.Coordinates); line.Name = payload.Name; line.Closed = payload.Closed; line.Properties = payload.Properties; return(line); }
public static SpeckleObject ToSpeckle(this Curve curve) { var properties = curve.UserDictionary.ToSpeckle(); if (curve is PolyCurve) { return((( PolyCurve )curve).ToSpeckle()); } if (curve.IsArc()) { Arc getObj; curve.TryGetArc(out getObj); SpeckleArc myObject = getObj.ToSpeckle(); myObject.Properties = properties; return(myObject); } if (curve.IsCircle()) { Circle getObj; curve.TryGetCircle(out getObj); SpeckleCircle myObject = getObj.ToSpeckle(); myObject.Properties = properties; return(myObject); } if (curve.IsEllipse()) { Ellipse getObj; curve.TryGetEllipse(out getObj); SpeckleEllipse myObject = getObj.ToSpeckle(); myObject.Properties = properties; return(myObject); } if (curve.IsLinear() || curve.IsPolyline()) // defaults to polyline { Polyline getObj; curve.TryGetPolyline(out getObj); SpecklePolyline myObject = getObj.ToSpeckle(); myObject.Properties = properties; return(myObject); } Polyline poly; curve.ToPolyline(0, 1, 0, 0, 0, 0.1, 0, 0, true).TryGetPolyline(out poly); SpeckleCurve myCurve = new SpeckleCurve(poly.ToSpeckle(), properties: curve.UserDictionary.ToSpeckle()); NurbsCurve nurbsCurve = curve.ToNurbsCurve(); myCurve.Weights = nurbsCurve.Points.Select(ctp => ctp.Weight).ToArray(); myCurve.Points = nurbsCurve.Points.Select(ctp => ctp.Location).ToFlatArray(); myCurve.Knots = nurbsCurve.Knots.ToArray(); myCurve.Degree = nurbsCurve.Degree; myCurve.Periodic = nurbsCurve.IsPeriodic; myCurve.Rational = nurbsCurve.IsRational; myCurve.Domain = nurbsCurve.Domain.ToSpeckle(); myCurve.Properties = properties; return(myCurve); }
/// <summary> /// SpecklePolyline to DS Rectangle if closed , four points and sides parallel; /// DS Polygon if closed or DS Polycurve otherwise /// </summary> /// <param name="polyline"></param> /// <returns></returns> public static Curve ToNative(this SpecklePolyline polyline) { var points = polyline.Value.ToPoints(); if (polyline.Closed) { return(PolyCurve.ByPoints(points).CloseWithLine().SetSpeckleProperties <PolyCurve>(polyline.Properties)); } return(PolyCurve.ByPoints(points).SetSpeckleProperties <PolyCurve>(polyline.Properties)); }
public static SpeckleObject ToSpeckle(this NurbsCurve curve) { SpeckleObject speckleCurve; if (curve.IsLinear()) { using (Line line = curve.GetAsLine()) { speckleCurve = line.ToSpeckle(); } } else if (curve.IsArc()) { using (Arc arc = curve.GetAsArc()) { speckleCurve = arc.ToSpeckle(); } } else if (curve.IsCircle()) { using (Circle circle = curve.GetAsCircle()) { speckleCurve = circle.ToSpeckle(); } } else if (curve.IsEllipse()) { using (Ellipse ellipse = curve.GetAsEllipse()) { speckleCurve = ellipse.ToSpeckle(); } } else { // SpeckleCurve DisplayValue Curve[] curves = curve.ApproximateWithArcAndLineSegments(); List <double> polylineCoordinates = curves.SelectMany(c => new Point[2] { c.StartPoint, c.EndPoint }.ToFlatArray()).ToList(); polylineCoordinates.AddRange(curves.Last().EndPoint.ToArray()); curves.ForEach(c => c.Dispose()); SpecklePolyline displayValue = new SpecklePolyline(polylineCoordinates); List <double> dsKnots = curve.Knots().ToList(); dsKnots.RemoveAt(dsKnots.Count - 1); dsKnots.RemoveAt(0); SpeckleCurve spkCurve = new SpeckleCurve(displayValue); spkCurve.Weights = curve.Weights().ToList(); spkCurve.Points = curve.ControlPoints().ToFlatArray().ToList(); spkCurve.Knots = dsKnots; spkCurve.Degree = curve.Degree; spkCurve.Periodic = curve.IsPeriodic; spkCurve.Rational = curve.IsRational; spkCurve.Closed = curve.IsClosed; spkCurve.Domain = new SpeckleInterval(curve.StartParameter(), curve.EndParameter()); //spkCurve.Properties spkCurve.GenerateHash(); speckleCurve = spkCurve; } speckleCurve.Properties = curve.GetSpeckleProperties(); return(speckleCurve); }
// Rh Capture public static SpecklePolyline ToSpeckle(this PolylineCurve poly) { Polyline polyline; if (poly.TryGetPolyline(out polyline)) { var myPoly = new SpecklePolyline(polyline.ToFlatArray()); myPoly.Properties = poly.UserDictionary.ToSpeckle(); return(myPoly); } return(null); }
public static GameObject ToNative(this SpecklePolyline pl) { GameObject go = BaseLineObject(); go.GetComponent<UnitySpeckleObjectData>().Id = pl._id; go.GetComponent<UnitySpeckleObjectData>().speckleObject = pl; Vector3[] pts = pl.Value.ToPoints(); go.GetComponent<LineRenderer>().positionCount = pts.Count(); go.GetComponent<LineRenderer>().SetPositions(pts); return go; }
/// <summary> /// /// </summary> /// <param name="polyline"></param> /// <returns></returns> public static SpeckleUnityPolyline ToNative(this SpecklePolyline polyline) { Vector3[] points = polyline.Value.ToPoints(); if (points.Length == 0) { return(null); } polyline.Scale(scaleFactor); return(new SpeckleUnityPolyline(polyline.Type, points)); }
public static string ToNative(this SpecklePolyline inputObject) { var convertedObject = new Structural1DElementPolyline(); foreach (var p in convertedObject.GetType().GetProperties().Where(p => p.CanWrite)) { var inputProperty = inputObject.GetType().GetProperty(p.Name); if (inputProperty != null) p.SetValue(convertedObject, inputProperty.GetValue(inputObject)); } return convertedObject.ToNative(); }
public static SpecklePolyline ToSpeckle(this BHG.Polyline polyline) { if (polyline == null) { return(default(SpecklePolyline)); } SpecklePolyline specklePolyline = new SpecklePolyline(polyline.ControlPoints.SelectMany(p => new List <double> { p.X, p.Y, p.Z })); return(specklePolyline); }
// Deserialise public static PolylineCurve ToNative(this SpecklePolyline poly) { var points = poly.Value.ToPoints().ToList(); if (poly.Closed) { points.Add(points[0]); } var myPoly = new PolylineCurve(points); if (poly.Domain != null) { myPoly.Domain = poly.Domain.ToNative(); } myPoly.UserDictionary.ReplaceContentsWith(poly.Properties.ToNative()); return(myPoly); }
// Polyline // Gh Capture public static SpeckleObject ToSpeckle(this Polyline poly) { if (poly.Count == 2) { return(new SpeckleLine(poly.ToFlatArray())); } var myPoly = new SpecklePolyline(poly.ToFlatArray()); myPoly.Closed = poly.IsClosed; if (myPoly.Closed) { myPoly.Value.RemoveRange(myPoly.Value.Count - 3, 3); } return(myPoly); }
// Curve public static SpeckleObject ToSpeckle(this NurbsCurve curve) { var properties = curve.UserDictionary.ToSpeckle(root: curve); if (curve.IsArc(Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance)) { Arc getObj; curve.TryGetArc(out getObj); SpeckleArc myObject = getObj.ToSpeckle(); myObject.Properties = properties; myObject.GenerateHash(); return(myObject); } if (curve.IsCircle(Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance)) { Circle getObj; curve.TryGetCircle(out getObj); SpeckleCircle myObject = getObj.ToSpeckle(); myObject.Properties = properties; myObject.GenerateHash(); return(myObject); } if (curve.IsEllipse(Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance)) { Ellipse getObj; curve.TryGetEllipse(out getObj); SpeckleEllipse myObject = getObj.ToSpeckle(); myObject.Properties = properties; myObject.GenerateHash(); return(myObject); } if (curve.IsLinear(Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance) || curve.IsPolyline()) // defaults to polyline { Polyline getObj; curve.TryGetPolyline(out getObj); SpeckleObject myObject = getObj.ToSpeckle(); myObject.Properties = properties; myObject.GenerateHash(); return(myObject); } Polyline poly; curve.ToPolyline(0, 1, 0, 0, 0, 0.1, 0, 0, true).TryGetPolyline(out poly); SpecklePolyline displayValue; if (poly.Count == 2) { displayValue = new SpecklePolyline(); displayValue.Value = new List <double> { poly[0].X, poly[0].Y, poly[0].Z, poly[1].X, poly[1].Y, poly[1].Z }; displayValue.GenerateHash(); } else { displayValue = poly.ToSpeckle() as SpecklePolyline; } SpeckleCurve myCurve = new SpeckleCurve(displayValue); NurbsCurve nurbsCurve = curve.ToNurbsCurve(); myCurve.Weights = nurbsCurve.Points.Select(ctp => ctp.Weight).ToList(); myCurve.Points = nurbsCurve.Points.Select(ctp => ctp.Location).ToFlatArray().ToList(); myCurve.Knots = nurbsCurve.Knots.ToList(); myCurve.Degree = nurbsCurve.Degree; myCurve.Periodic = nurbsCurve.IsPeriodic; myCurve.Rational = nurbsCurve.IsRational; myCurve.Domain = nurbsCurve.Domain.ToSpeckle(); myCurve.Closed = nurbsCurve.IsClosed; myCurve.Properties = properties; myCurve.GenerateHash(); return(myCurve); }
public static List <SpeckleObject> ToSpeckle(this AnalyticalModelStick myStick) { var returnObjects = new List <SpeckleObject>(); if (!myStick.IsEnabled()) { return(new List <SpeckleObject>()); } // Get the family var myFamily = (FamilyInstance)Doc.GetElement(myStick.GetElementId()); var myElement = new Structural1DElementPolyline { Value = new List <double>() }; var curves = myStick.GetCurves(AnalyticalCurveType.RigidLinkHead).ToList(); curves.AddRange(myStick.GetCurves(AnalyticalCurveType.ActiveCurves)); curves.AddRange(myStick.GetCurves(AnalyticalCurveType.RigidLinkTail)); foreach (var curve in curves) { var points = curve.Tessellate(); if (points.Count == 0) { continue; } if (myElement.Value.Count == 0) { myElement.Value.Add(points[0].X / Scale); myElement.Value.Add(points[0].Y / Scale); myElement.Value.Add(points[0].Z / Scale); } foreach (var p in points.Skip(1)) { myElement.Value.Add(p.X / Scale); myElement.Value.Add(p.Y / Scale); myElement.Value.Add(p.Z / Scale); } } myElement.ResultVertices = new List <double>(myElement.Value); var vertexCount = myElement.Value.Count / 3; var coordinateSystem = myStick.GetLocalCoordinateSystem(); if (coordinateSystem != null) { myElement.ZAxis = Enumerable.Repeat(new StructuralVectorThree(new double[] { coordinateSystem.BasisZ.X, coordinateSystem.BasisZ.Y, coordinateSystem.BasisZ.Z }), (vertexCount - 1)).ToList(); } try { var offset1 = myStick.GetOffset(AnalyticalElementSelector.StartOrBase); var offset2 = myStick.GetOffset(AnalyticalElementSelector.EndOrTop); // TODO: This should be linear interpolation? var fillerList = Enumerable.Repeat(new StructuralVectorThree(new double[] { 0, 0, 0 }), (vertexCount - 1) * 2 - 2).ToList(); myElement.Offset = new List <StructuralVectorThree>() { new StructuralVectorThree(new double[] { offset1.X / Scale, offset1.Y / Scale, offset1.Z / Scale }) } .Concat(fillerList) .Concat(new List <StructuralVectorThree>() { new StructuralVectorThree(new double[] { offset2.X / Scale, offset2.Y / Scale, offset2.Z / Scale }) }).ToList(); } catch { try { var offset = myStick.GetOffset(AnalyticalElementSelector.Whole); myElement.Offset = Enumerable.Repeat(new StructuralVectorThree(new double[] { offset.X / Scale, offset.Y / Scale, offset.Z / Scale }), (vertexCount - 1) * 2).ToList(); } catch { } } if (myStick is AnalyticalModelColumn) { StructuralVectorBoolSix endRelease1 = null, endRelease2 = null; switch (myStick.get_Parameter(BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_TYPE).AsInteger()) { case 0: endRelease1 = new StructuralVectorBoolSix(new bool[] { false, false, false, false, false, false }); break; case 1: endRelease1 = new StructuralVectorBoolSix(new bool[] { false, false, false, true, true, true }); break; case 2: endRelease1 = new StructuralVectorBoolSix(new bool[] { false, false, false, false, true, true }); break; case 3: endRelease1 = new StructuralVectorBoolSix(new bool[] { myStick.get_Parameter(BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_FX).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_FY).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_FZ).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_MX).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_MY).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_BOTTOM_RELEASE_MZ).AsInteger() == 1, }); break; } switch (myStick.get_Parameter(BuiltInParameter.STRUCTURAL_TOP_RELEASE_TYPE).AsInteger()) { case 0: endRelease2 = new StructuralVectorBoolSix(new bool[] { false, false, false, false, false, false }); break; case 1: endRelease2 = new StructuralVectorBoolSix(new bool[] { false, false, false, true, true, true }); break; case 2: endRelease2 = new StructuralVectorBoolSix(new bool[] { false, false, false, false, true, true }); break; case 3: endRelease2 = new StructuralVectorBoolSix(new bool[] { myStick.get_Parameter(BuiltInParameter.STRUCTURAL_TOP_RELEASE_FX).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_TOP_RELEASE_FY).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_TOP_RELEASE_FZ).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_TOP_RELEASE_MX).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_TOP_RELEASE_MY).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_TOP_RELEASE_MZ).AsInteger() == 1, }); break; } var fillerList = Enumerable.Repeat(new StructuralVectorBoolSix(new bool[] { false, false, false, false, false, false }), (vertexCount - 1) * 2 - 2).ToList(); myElement.EndRelease = new List <StructuralVectorBoolSix>() { endRelease1 }.Concat(fillerList).Concat(new List <StructuralVectorBoolSix>() { endRelease2 }).ToList(); } else { StructuralVectorBoolSix endRelease1 = null, endRelease2 = null; switch (myStick.get_Parameter(BuiltInParameter.STRUCTURAL_START_RELEASE_TYPE).AsInteger()) { case 0: endRelease1 = new StructuralVectorBoolSix(new bool[] { false, false, false, false, false, false }); break; case 1: endRelease1 = new StructuralVectorBoolSix(new bool[] { false, false, false, true, true, true }); break; case 2: endRelease1 = new StructuralVectorBoolSix(new bool[] { false, false, false, false, true, true }); break; case 3: endRelease1 = new StructuralVectorBoolSix(new bool[] { myStick.get_Parameter(BuiltInParameter.STRUCTURAL_START_RELEASE_FX).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_START_RELEASE_FY).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_START_RELEASE_FZ).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_START_RELEASE_MX).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_START_RELEASE_MY).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_START_RELEASE_MZ).AsInteger() == 1, }); break; } switch (myStick.get_Parameter(BuiltInParameter.STRUCTURAL_END_RELEASE_TYPE).AsInteger()) { case 0: endRelease2 = new StructuralVectorBoolSix(new bool[] { false, false, false, false, false, false }); break; case 1: endRelease2 = new StructuralVectorBoolSix(new bool[] { false, false, false, true, true, true }); break; case 2: endRelease2 = new StructuralVectorBoolSix(new bool[] { false, false, false, false, true, true }); break; case 3: endRelease2 = new StructuralVectorBoolSix(new bool[] { myStick.get_Parameter(BuiltInParameter.STRUCTURAL_END_RELEASE_FX).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_END_RELEASE_FY).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_END_RELEASE_FZ).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_END_RELEASE_MX).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_END_RELEASE_MY).AsInteger() == 1, myStick.get_Parameter(BuiltInParameter.STRUCTURAL_END_RELEASE_MZ).AsInteger() == 1, }); break; } var fillerList = Enumerable.Repeat(new StructuralVectorBoolSix(new bool[] { false, false, false, false, false, false }), (vertexCount - 1) * 2 - 2).ToList(); myElement.EndRelease = new List <StructuralVectorBoolSix>() { endRelease1 }.Concat(fillerList).Concat(new List <StructuralVectorBoolSix>() { endRelease2 }).ToList(); } // Property try { var mySection = new Structural1DProperty { Name = Doc.GetElement(myStick.GetElementId()).Name, ApplicationId = myFamily.Symbol.UniqueId }; switch (myFamily.Symbol.GetStructuralSection().StructuralSectionGeneralShape) { case Autodesk.Revit.DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralI: mySection.Shape = Structural1DPropertyShape.I; mySection.Hollow = false; break; case Autodesk.Revit.DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralT: mySection.Shape = Structural1DPropertyShape.T; mySection.Hollow = false; break; case Autodesk.Revit.DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralH: mySection.Shape = Structural1DPropertyShape.Rectangular; mySection.Hollow = true; mySection.Thickness = (double)typeof(Autodesk.Revit.DB.Structure.StructuralSections.StructuralSectionGeneralH).GetProperty("WallNominalThickness").GetValue(myFamily.Symbol.GetStructuralSection()) / Scale; break; case Autodesk.Revit.DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralR: mySection.Shape = Structural1DPropertyShape.Circular; mySection.Hollow = true; mySection.Thickness = (double)typeof(Autodesk.Revit.DB.Structure.StructuralSections.StructuralSectionGeneralR).GetProperty("WallNominalThickness").GetValue(myFamily.Symbol.GetStructuralSection()) / Scale; mySection.Profile = new SpeckleCircle( new SpecklePlane(new SpecklePoint(0, 0, 0), new SpeckleVector(0, 0, 1), new SpeckleVector(1, 0, 0), new SpeckleVector(0, 1, 0)), (double)typeof(Autodesk.Revit.DB.Structure.StructuralSections.StructuralSectionGeneralR).GetProperty("Diameter").GetValue(myFamily.Symbol.GetStructuralSection()) / 2 / Scale); break; case Autodesk.Revit.DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralF: mySection.Shape = Structural1DPropertyShape.Rectangular; mySection.Hollow = false; break; case Autodesk.Revit.DB.Structure.StructuralSections.StructuralSectionGeneralShape.GeneralS: mySection.Shape = Structural1DPropertyShape.Circular; mySection.Profile = new SpeckleCircle( new SpecklePlane(new SpecklePoint(0, 0, 0), new SpeckleVector(0, 0, 1), new SpeckleVector(1, 0, 0), new SpeckleVector(0, 1, 0)), (double)typeof(Autodesk.Revit.DB.Structure.StructuralSections.StructuralSectionGeneralR).GetProperty("Diameter").GetValue(myFamily.Symbol.GetStructuralSection()) / 2 / Scale); mySection.Hollow = false; break; default: mySection.Shape = Structural1DPropertyShape.Generic; mySection.Hollow = false; break; } // Generate section profile var profile = myFamily.GetSweptProfile().GetSweptProfile(); if (mySection.Shape != Structural1DPropertyShape.Circular) { var myProfile = new SpecklePolyline { Value = new List <double>() }; for (var i = 0; i < profile.Curves.Size; i++) { var sectionCurves = SpeckleCore.Converter.Serialise(profile.Curves.get_Item(i)); var sectionCoordinates = new List <double>(); var nextCoordinates = new List <double>(); if (sectionCurves is SpeckleLine) { sectionCoordinates = (sectionCurves as SpeckleLine).Value.Select(x => Math.Round(x, 10)).ToList(); if (myProfile.Value.Count == 0) { myProfile.Value = sectionCoordinates; continue; } if (myProfile.Value.Skip(myProfile.Value.Count - 3).SequenceEqual(sectionCoordinates.Take(3))) { nextCoordinates = sectionCoordinates.Skip(3).ToList(); } else { break; } } else if (sectionCurves is SpeckleArc) { if (myProfile.Value.Count == 0) { myProfile.Value = (sectionCurves as SpeckleArc).StartPoint.Value.Select(x => Math.Round(x, 10)) .Concat((sectionCurves as SpeckleArc).MidPoint.Value.Select(x => Math.Round(x, 10))) .Concat((sectionCurves as SpeckleArc).EndPoint.Value.Select(x => Math.Round(x, 10))) .ToList(); continue; } if (myProfile.Value.Skip(myProfile.Value.Count - 3).SequenceEqual((sectionCurves as SpeckleArc).StartPoint.Value.Select(x => Math.Round(x, 10)))) { nextCoordinates = (sectionCurves as SpeckleArc).EndPoint.Value.Select(x => Math.Round(x, 10)).ToList(); } else if (myProfile.Value.Skip(myProfile.Value.Count - 3).SequenceEqual((sectionCurves as SpeckleArc).EndPoint.Value.Select(x => Math.Round(x, 10)))) { nextCoordinates = (sectionCurves as SpeckleArc).StartPoint.Value.Select(x => Math.Round(x, 10)).ToList(); } else { break; } } if (nextCoordinates.SequenceEqual(myProfile.Value.Take(3))) { myProfile.Closed = true; break; } else { myProfile.Value.AddRange(nextCoordinates); } } myProfile.GenerateHash(); mySection.Profile = myProfile; } // Material try { var matType = myFamily.StructuralMaterialType; var structMat = (Material)Doc.GetElement(myFamily.StructuralMaterialId); if (structMat == null) { structMat = (Material)Doc.GetElement(myFamily.Symbol.get_Parameter(BuiltInParameter.STRUCTURAL_MATERIAL_PARAM).AsElementId()); } var matAsset = ((PropertySetElement)Doc.GetElement(structMat.StructuralAssetId)).GetStructuralAsset(); SpeckleObject myMaterial = null; switch (matType) { case Autodesk.Revit.DB.Structure.StructuralMaterialType.Concrete: var concMat = new StructuralMaterialConcrete { ApplicationId = Doc.GetElement(myFamily.StructuralMaterialId).UniqueId, Name = Doc.GetElement(myFamily.StructuralMaterialId).Name, YoungsModulus = matAsset.YoungModulus.X, ShearModulus = matAsset.ShearModulus.X, PoissonsRatio = matAsset.PoissonRatio.X, Density = matAsset.Density, CoeffThermalExpansion = matAsset.ThermalExpansionCoefficient.X, CompressiveStrength = matAsset.ConcreteCompression, MaxStrain = 0, AggragateSize = 0 }; myMaterial = concMat; break; case Autodesk.Revit.DB.Structure.StructuralMaterialType.Steel: var steelMat = new StructuralMaterialSteel { ApplicationId = Doc.GetElement(myFamily.StructuralMaterialId).UniqueId, Name = Doc.GetElement(myFamily.StructuralMaterialId).Name, YoungsModulus = matAsset.YoungModulus.X, ShearModulus = matAsset.ShearModulus.X, PoissonsRatio = matAsset.PoissonRatio.X, Density = matAsset.Density, CoeffThermalExpansion = matAsset.ThermalExpansionCoefficient.X, YieldStrength = matAsset.MinimumYieldStress, UltimateStrength = matAsset.MinimumTensileStrength, MaxStrain = 0 }; myMaterial = steelMat; break; default: var defMat = new StructuralMaterialSteel { ApplicationId = Doc.GetElement(myFamily.StructuralMaterialId).UniqueId, Name = Doc.GetElement(myFamily.StructuralMaterialId).Name }; myMaterial = defMat; break; } myMaterial.GenerateHash(); mySection.MaterialRef = (myMaterial as SpeckleObject).ApplicationId; returnObjects.Add(myMaterial); } catch { } mySection.GenerateHash(); myElement.PropertyRef = mySection.ApplicationId; returnObjects.Add(mySection); } catch { } myElement.GenerateHash(); myElement.ApplicationId = myStick.UniqueId; returnObjects.Add(myElement); return(returnObjects); }