private Structural1DProperty SetDesc(Structural1DProperty prop, string desc, string gsaUnit)
        {
            var pieces = desc.ListSplit("%");

            switch (pieces[0])
            {
            case "STD":
                return(SetStandardDesc(prop, desc, gsaUnit));

            case "GEO":
                return(SetGeometryDesc(prop, desc, gsaUnit));

            case "CAT":
                var transformed = TransformCategorySection(desc);
                if (transformed == null)
                {
                    return(prop);
                }
                prop.CatalogueName = pieces[2];
                return(SetStandardDesc(prop, transformed, gsaUnit));

            default:
                return(prop);
            }
        }
 public static string ToNative(this Structural1DProperty prop)
 {
     return(new GSA1DProperty()
     {
         Value = prop
     }.SetGWACommand(Initialiser.Settings.Units));
 }
예제 #3
0
 public static string ToNative(this Structural1DProperty prop)
 {
     return(SchemaConversion.Helper.ToNativeTryCatch(prop, () => new GSA1DProperty()
     {
         Value = prop
     }.SetGWACommand(Initialiser.AppResources.Settings.Units)));
 }
        public void ParseGWACommand(string GSAUnits, List <GSAMaterialSteel> steels, List <GSAMaterialConcrete> concretes)
        {
            if (this.GWACommand == null)
            {
                return;
            }

            var obj = new Structural1DProperty();

            var pieces = this.GWACommand.ListSplit("\t");

            var counter = 1; // Skip identifier

            this.GSAId        = Convert.ToInt32(pieces[counter++]);
            obj.ApplicationId = Helper.GetApplicationId(this.GetGSAKeyword(), this.GSAId);
            obj.Name          = pieces[counter++].Trim(new char[] { '"' });
            counter++; // Color
            var materialType  = pieces[counter++];
            var materialGrade = pieces[counter++];

            if (materialType == "STEEL")
            {
                if (steels != null)
                {
                    var matchingMaterial = steels.Where(m => m.GSAId.ToString() == materialGrade).FirstOrDefault();
                    obj.MaterialRef = matchingMaterial == null ? null : matchingMaterial.Value.ApplicationId;
                    if (matchingMaterial != null)
                    {
                        this.SubGWACommand.Add(matchingMaterial.GWACommand);
                    }
                }
            }
            else if (materialType == "CONCRETE")
            {
                if (concretes != null)
                {
                    var matchingMaterial = concretes.Where(m => m.GSAId.ToString() == materialGrade).FirstOrDefault();
                    obj.MaterialRef = matchingMaterial == null ? null : matchingMaterial.Value.ApplicationId;
                    if (matchingMaterial != null)
                    {
                        this.SubGWACommand.Add(matchingMaterial.GWACommand);
                    }
                }
            }

            counter++; // Analysis material
            var shapeDesc = pieces[counter++];

            counter++; // Cost

            obj = SetDesc(obj, shapeDesc, GSAUnits);

            this.Value = obj;
        }
        private Structural1DProperty SetGeometryDesc(Structural1DProperty prop, string desc, string gsaUnit)
        {
            var pieces = desc.ListSplit("%");

            var unit = Regex.Match(pieces[1], @"(?<=()(.*?)(?=))").Value;

            if (unit == "")
            {
                unit = "mm";
            }

            var type = pieces[1].Split(new char[] { '(' })[0];

            if (type == "P")
            {
                // Perimeter Section
                var coor = new List <double>();

                var points = Regex.Matches(desc, @"(?<=\()(.*?)(?=\))");
                foreach (Match point in points)
                {
                    try
                    {
                        var n = point.Value.Split(new char[] { '|' });

                        coor.Add(Convert.ToDouble(n[0]).ConvertUnit(unit, gsaUnit));
                        coor.Add(Convert.ToDouble(n[1]).ConvertUnit(unit, gsaUnit));
                        coor.Add(0);
                    }
                    catch { }
                }

                prop.Profile = new SpecklePolyline(coor.ToArray());
                (prop.Profile as SpecklePolyline).Closed = true;
                prop.Shape  = Structural1DPropertyShape.Generic;
                prop.Hollow = false;
                return(prop);
            }
            else
            {
                // TODO: IMPLEMENT ALL SECTIONS
                return(prop);
            }
        }
예제 #6
0
        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);
        }
        private string GetGSADesc(Structural1DProperty prop, string gsaUnit)
        {
            if (!string.IsNullOrEmpty(prop.CatalogueName))
            {
                var desc = GetGSACategorySection(prop.CatalogueName);
                if (!string.IsNullOrEmpty(desc))
                {
                    return(desc);
                }
            }

            if (prop.Profile == null)
            {
                return("");
            }

            if (prop.Profile is SpeckleCircle)
            {
                var profile = prop.Profile as SpeckleCircle;

                if (prop.Hollow.HasValue && prop.Hollow.Value)
                {
                    return("STD%CHS(" + gsaUnit + ")%" + (profile.Radius * 2).ToString() + "%" + prop.Thickness.ToString());
                }
                else
                {
                    return("STD%C(" + gsaUnit + ")%" + (profile.Radius * 2).ToString());
                }
            }

            if (prop.Profile is SpecklePolyline)
            {
                var X = (prop.Profile as SpecklePolyline).Value.Where((x, i) => i % 3 == 0).ToList();
                var Y = (prop.Profile as SpecklePolyline).Value.Where((x, i) => i % 3 == 1).ToList();
                if (prop.Shape == Structural1DPropertyShape.Circular)
                {
                    if (prop.Hollow.HasValue && prop.Hollow.Value)
                    {
                        return("STD%CHS(" + gsaUnit + ")%" + (X.Max() - X.Min()).ToString() + "%" + prop.Thickness.ToString());
                    }
                    else
                    {
                        return("STD%C(" + gsaUnit + ")%" + (X.Max() - X.Min()).ToString());
                    }
                }
                else if (prop.Shape == Structural1DPropertyShape.Rectangular)
                {
                    if (prop.Hollow.HasValue && prop.Hollow.Value)
                    {
                        return("STD%RHS(" + gsaUnit + ")%" + (Y.Max() - Y.Min()).ToString() + "%" + (X.Max() - X.Min()).ToString() + "%" + prop.Thickness.ToString() + "%" + prop.Thickness.ToString());
                    }
                    else
                    {
                        return("STD%R(" + gsaUnit + ")%" + (Y.Max() - Y.Min()).ToString() + "%" + (X.Max() - X.Min()).ToString());
                    }
                }
                else if (prop.Shape == Structural1DPropertyShape.I)
                {
                    var xDist = X.Distinct().ToList();
                    var yDist = Y.Distinct().ToList();

                    xDist.Sort();
                    yDist.Sort();

                    if (xDist.Count() == 4 && yDist.Count() == 4)
                    {
                        var width = xDist.Max() - xDist.Min();
                        var depth = yDist.Max() - yDist.Min();
                        var T     = yDist[3] - yDist[2];
                        var t     = xDist[2] - xDist[1];

                        return("STD%I(" + gsaUnit + ")%" + depth.ToString() + "%" + width.ToString() + "%" + T.ToString() + "%" + t.ToString());
                    }
                }
                else if (prop.Shape == Structural1DPropertyShape.T)
                {
                    var xDist = X.Distinct().ToList();
                    var yDist = Y.Distinct().ToList();

                    xDist.Sort();
                    yDist.Sort();

                    if (xDist.Count() == 4 && yDist.Count() == 3)
                    {
                        var width = xDist.Max() - xDist.Min();
                        var depth = yDist.Max() - yDist.Min();
                        var T     = yDist[2] - yDist[1];
                        var t     = xDist[2] - xDist[1];

                        return("STD%T(" + gsaUnit + ")%" + depth.ToString() + "%" + width.ToString() + "%" + T.ToString() + "%" + t.ToString());
                    }
                }
                // Structural1DPropertyShape.Generic



                if (X.Count() < 3 || Y.Count() < 3)
                {
                    return("");
                }

                var ls = new List <string>
                {
                    "GEO"
                };
                ls.Add((gsaUnit == "mm") ? "P" : "P(" + gsaUnit + ")");

                for (var i = 0; i < X.Count(); i++)
                {
                    var point = ((i == 0) ? "M" : "L") + "(" + X[i].ToString() + "|" + Y[i].ToString() + ")";

                    ls.Add(point);
                }

                if (prop.Voids != null && prop.Voids.Count() > 0)
                {
                    foreach (var propVoid in prop.Voids)
                    {
                        X = (propVoid as SpecklePolyline).Value.Where((x, i) => i % 3 == 0).ToList();
                        Y = (propVoid as SpecklePolyline).Value.Where((x, i) => i % 3 == 1).ToList();

                        for (var i = 0; i < X.Count(); i++)
                        {
                            var point = ((i == 0) ? "M" : "L") + "(" + X[i].ToString() + "|" + Y[i].ToString() + ")";

                            ls.Add(point);
                        }
                    }
                }

                return(string.Join("%", ls));
            }

            return("");
        }
        private Structural1DProperty SetStandardDesc(Structural1DProperty prop, string desc, string gsaUnit)
        {
            var pieces = desc.ListSplit("%");

            var unit = Regex.Match(pieces[1], @"(?<=\()(.+)(?=\))").Value;

            if (unit == "")
            {
                unit = "mm";
            }

            var type = pieces[1].Split(new char[] { '(' })[0];

            if (type == "R")
            {
                // Rectangle
                var height = Convert.ToDouble(pieces[2]).ConvertUnit(unit, gsaUnit);
                var width  = Convert.ToDouble(pieces[3]).ConvertUnit(unit, gsaUnit);
                prop.Profile = new SpecklePolyline(new double[] {
                    width / 2, height / 2, 0,
                    -width / 2, height / 2, 0,
                    -width / 2, -height / 2, 0,
                    width / 2, -height / 2, 0
                });
                (prop.Profile as SpecklePolyline).Closed = true;
                prop.Shape  = Structural1DPropertyShape.Rectangular;
                prop.Hollow = false;
            }
            else if (type == "RHS")
            {
                // Hollow Rectangle
                var    height = Convert.ToDouble(pieces[2]).ConvertUnit(unit, gsaUnit);
                var    width  = Convert.ToDouble(pieces[3]).ConvertUnit(unit, gsaUnit);
                var    t1     = Convert.ToDouble(pieces[4]).ConvertUnit(unit, gsaUnit);
                double t2     = 0;
                try
                {
                    t2 = Convert.ToDouble(pieces[5]).ConvertUnit(unit, gsaUnit);
                }
                catch { t2 = t1; }
                prop.Profile = new SpecklePolyline(new double[] {
                    width / 2, height / 2, 0,
                    -width / 2, height / 2, 0,
                    -width / 2, -height / 2, 0,
                    width / 2, -height / 2, 0
                });
                (prop.Profile as SpecklePolyline).Closed = true;
                prop.Shape     = Structural1DPropertyShape.Rectangular;
                prop.Hollow    = true;
                prop.Thickness = (t1 + t2) / 2; // TODO: Takes average thickness
            }
            else if (type == "C")
            {
                // Circle
                var diameter = Convert.ToDouble(pieces[2]).ConvertUnit(unit, gsaUnit);
                prop.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)),
                    diameter / 2);
                prop.Shape  = Structural1DPropertyShape.Circular;
                prop.Hollow = false;
            }
            else if (type == "CHS")
            {
                // Hollow Circle
                var diameter = Convert.ToDouble(pieces[2]).ConvertUnit(unit, gsaUnit);
                var t        = Convert.ToDouble(pieces[3]).ConvertUnit(unit, gsaUnit);
                prop.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)),
                    diameter / 2);
                prop.Shape     = Structural1DPropertyShape.Circular;
                prop.Hollow    = true;
                prop.Thickness = t;
            }
            else if (type == "I")
            {
                // I Section
                var depth           = Convert.ToDouble(pieces[2]).ConvertUnit(unit, gsaUnit);
                var width           = Convert.ToDouble(pieces[3]).ConvertUnit(unit, gsaUnit);
                var webThickness    = Convert.ToDouble(pieces[4]).ConvertUnit(unit, gsaUnit);
                var flangeThickness = Convert.ToDouble(pieces[5]).ConvertUnit(unit, gsaUnit);

                prop.Profile = new SpecklePolyline(new double[] {
                    webThickness / 2, depth / 2 - flangeThickness, 0,
                    width / 2, depth / 2 - flangeThickness, 0,
                    width / 2, depth / 2, 0,
                    -width / 2, depth / 2, 0,
                    -width / 2, depth / 2 - flangeThickness, 0,
                    -webThickness / 2, depth / 2 - flangeThickness, 0,
                    -webThickness / 2, -(depth / 2 - flangeThickness), 0,
                    -width / 2, -(depth / 2 - flangeThickness), 0,
                    -width / 2, -depth / 2, 0,
                    width / 2, -depth / 2, 0,
                    width / 2, -(depth / 2 - flangeThickness), 0,
                    webThickness / 2, -(depth / 2 - flangeThickness), 0
                });
                (prop.Profile as SpecklePolyline).Closed = true;
                prop.Shape  = Structural1DPropertyShape.I;
                prop.Hollow = false;
            }
            else if (type == "T")
            {
                // T Section
                var depth           = Convert.ToDouble(pieces[2]).ConvertUnit(unit, gsaUnit);
                var width           = Convert.ToDouble(pieces[3]).ConvertUnit(unit, gsaUnit);
                var webThickness    = Convert.ToDouble(pieces[4]).ConvertUnit(unit, gsaUnit);
                var flangeThickness = Convert.ToDouble(pieces[5]).ConvertUnit(unit, gsaUnit);

                prop.Profile = new SpecklePolyline(new double[] {
                    webThickness / 2, -flangeThickness, 0,
                    width / 2, -flangeThickness, 0,
                    width / 2, 0, 0,
                    -width / 2, 0, 0,
                    -width / 2, -flangeThickness, 0,
                    -webThickness / 2, -flangeThickness, 0,
                    -webThickness / 2, -depth, 0,
                    webThickness / 2, -depth, 0
                });
                (prop.Profile as SpecklePolyline).Closed = true;
                prop.Shape  = Structural1DPropertyShape.T;
                prop.Hollow = false;
            }
            else if (type == "CH")
            {
                // Channel Section
                var depth           = Convert.ToDouble(pieces[2]).ConvertUnit(unit, gsaUnit);
                var width           = Convert.ToDouble(pieces[3]).ConvertUnit(unit, gsaUnit);
                var webThickness    = Convert.ToDouble(pieces[4]).ConvertUnit(unit, gsaUnit);
                var flangeThickness = Convert.ToDouble(pieces[5]).ConvertUnit(unit, gsaUnit);

                prop.Profile = new SpecklePolyline(new double[] {
                    webThickness, depth / 2 - flangeThickness, 0,
                    width, depth / 2 - flangeThickness, 0,
                    width, depth / 2, 0,
                    0, depth / 2, 0,
                    0, -depth / 2, 0,
                    width, -depth / 2, 0,
                    width, -(depth / 2 - flangeThickness), 0,
                    webThickness, -(depth / 2 - flangeThickness), 0
                });
                (prop.Profile as SpecklePolyline).Closed = true;
                prop.Shape  = Structural1DPropertyShape.Generic;
                prop.Hollow = false;
            }
            else if (type == "A")
            {
                // Angle Section
                var depth           = Convert.ToDouble(pieces[2]).ConvertUnit(unit, gsaUnit);
                var width           = Convert.ToDouble(pieces[3]).ConvertUnit(unit, gsaUnit);
                var webThickness    = Convert.ToDouble(pieces[4]).ConvertUnit(unit, gsaUnit);
                var flangeThickness = Convert.ToDouble(pieces[5]).ConvertUnit(unit, gsaUnit);

                prop.Profile = new SpecklePolyline(new double[] {
                    0, 0, 0,
                    width, 0, 0,
                    width, flangeThickness, 0,
                    webThickness, flangeThickness, 0,
                    webThickness, depth, 0,
                    0, depth, 0
                });
                (prop.Profile as SpecklePolyline).Closed = true;
                prop.Shape  = Structural1DPropertyShape.Generic;
                prop.Hollow = false;
            }
            else if (type == "TR")
            {
                // Taper Section
                var depth       = Convert.ToDouble(pieces[2]).ConvertUnit(unit, gsaUnit);
                var topWidth    = Convert.ToDouble(pieces[3]).ConvertUnit(unit, gsaUnit);
                var bottomWidth = Convert.ToDouble(pieces[4]).ConvertUnit(unit, gsaUnit);
                prop.Profile = new SpecklePolyline(new double[] {
                    topWidth / 2, depth / 2, 0,
                    -topWidth / 2, depth / 2, 0,
                    -bottomWidth / 2, -depth / 2, 0,
                    bottomWidth / 2, -depth / 2, 0
                });
                (prop.Profile as SpecklePolyline).Closed = true;
                prop.Shape  = Structural1DPropertyShape.Generic;
                prop.Hollow = false;
            }
            else if (type == "E")
            {
                // Ellipse Section
                var depth = Convert.ToDouble(pieces[2]).ConvertUnit(unit, gsaUnit);
                var width = Convert.ToDouble(pieces[3]).ConvertUnit(unit, gsaUnit);
                var index = Convert.ToInt32(pieces[4]);

                var coor = new List <double>();
                for (var i = 0; i < 360; i += 10)
                {
                    var radius =
                        depth * width / Math.Pow(
                            Math.Pow(depth * Math.Cos(i.ToRadians()), index)
                            + Math.Pow(width * Math.Sin(i.ToRadians()), index),
                            1 / index);

                    coor.Add(radius * Math.Cos(i.ToRadians()));
                    coor.Add(radius * Math.Sin(i.ToRadians()));
                    coor.Add(0);
                }
                prop.Profile = new SpecklePolyline(coor.ToArray());
                (prop.Profile as SpecklePolyline).Closed = true;
                prop.Shape  = Structural1DPropertyShape.Generic;
                prop.Hollow = false;
            }
            else if (type == "OVAL")
            {
                // Oval Section
                var depth     = Convert.ToDouble(pieces[2]).ConvertUnit(unit, gsaUnit);
                var width     = Convert.ToDouble(pieces[3]).ConvertUnit(unit, gsaUnit);
                var thickness = Convert.ToDouble(pieces[4]).ConvertUnit(unit, gsaUnit);

                var coor = new List <double>();
                for (var i = 0; i < 360; i += 10)
                {
                    var radius =
                        depth * width / Math.Pow(
                            Math.Pow(depth * Math.Cos(i.ToRadians()), 2)
                            + Math.Pow(width * Math.Sin(i.ToRadians()), 2),
                            1 / 2);

                    coor.Add(radius * Math.Cos(i.ToRadians()));
                    coor.Add(radius * Math.Sin(i.ToRadians()));
                    coor.Add(0);
                }
                prop.Profile = new SpecklePolyline(coor.ToArray());
                (prop.Profile as SpecklePolyline).Closed = true;
                prop.Shape     = Structural1DPropertyShape.Generic;
                prop.Hollow    = true;
                prop.Thickness = thickness;
            }
            else
            {
                // TODO: IMPLEMENT ALL SECTIONS
            }

            return(prop);
        }