public static string ToNative(this Structural1DPropertyExplicit prop)
        {
            if (string.IsNullOrEmpty(prop.ApplicationId))
            {
                return("");
            }

            var gsaSectionDict = new Dictionary <MaterialType, Func <Structural1DPropertyExplicit, int, GsaSection> >
            {
                { MaterialType.Concrete, ToGsaSectionConcrete },
                { MaterialType.Steel, ToGsaSectionSteel },
                { MaterialType.Generic, ToGsaSectionGeneric }
            };

            var keyword  = GsaRecord.GetKeyword <GsaSection>();
            var streamId = Initialiser.AppResources.Cache.LookupStream(prop.ApplicationId);
            var index    = Initialiser.AppResources.Cache.ResolveIndex(keyword, prop.ApplicationId);

            var materialIndex = 0;
            var materialType  = MaterialType.Generic;

            var materialSteelKeyword = typeof(GSAMaterialSteel).GetGSAKeyword();
            var materialConcKeyword  = typeof(GSAMaterialConcrete).GetGSAKeyword();

            var res = Initialiser.AppResources.Cache.LookupIndex(materialSteelKeyword, prop.MaterialRef);

            if (res.HasValue)
            {
                materialIndex = res.Value;
                materialType  = MaterialType.Steel;
            }
            else
            {
                res = Initialiser.AppResources.Cache.LookupIndex(materialConcKeyword, prop.MaterialRef);
                if (res.HasValue)
                {
                    materialIndex = res.Value;
                    materialType  = MaterialType.Concrete;
                }
                else
                {
                    //For generic, set index to 1 as a default
                    materialIndex = 1;
                }
            }

            var gsaSection = gsaSectionDict[materialType](prop, materialIndex);

            gsaSection.Index         = index;
            gsaSection.ApplicationId = prop.ApplicationId;
            gsaSection.Name          = prop.Name;

            if (gsaSection.Gwa(out var gwaLines, false))
            {
                Initialiser.AppResources.Cache.Upsert(keyword, index, gwaLines.First(), streamId, prop.ApplicationId, GsaRecord.GetGwaSetCommandType <GsaSection>());
            }

            return("");
        }
 private static GsaSection ToGsaSectionGeneric(Structural1DPropertyExplicit prop, int materialIndex)
 {
     return(new GsaSection
     {
         Components = new List <GsaSectionComponentBase>()
         {
             CreateSectionComp(Section1dMaterialType.GENERIC, materialIndex, prop.Area, prop.Iyy, prop.Izz, prop.J, prop.Ky, prop.Kz)
         }
     });
 }
예제 #3
0
        public static SpeckleObject ToSpeckle(this GsaSection dummyObject)
        {
            var newLines = Initialiser.AppResources.Cache.GetGwaToSerialise(dummyObject.Keyword);

            var structural1DPropertyExplicits = new List <Structural1DPropertyExplicit>();

            var concreteMaterials = Initialiser.GsaKit.GSASenderObjects.Get <GSAMaterialConcrete>().ToDictionary(o => o.GSAId, o => ((StructuralMaterialConcrete)o.SpeckleObject).ApplicationId);
            var steelMaterials    = Initialiser.GsaKit.GSASenderObjects.Get <GSAMaterialSteel>().ToDictionary(o => o.GSAId, o => ((StructuralMaterialSteel)o.SpeckleObject).ApplicationId);

            //Currently only handles explicit 1D properties
            //Filtering out all but explicit properties:
            //1.  First exclude any GWA lines with the exact string "EXP" - make first pass at filtering them out
            //2.  Call FromGwa for all and perform logic check of values of GsaSection (and subclass) instances
            var keysContainingEXP = newLines.Keys.Where(k => newLines[k].Contains("EXP")).ToList();
            var gsaSectionsExp    = new List <GsaSection>();

            foreach (var k in keysContainingEXP)
            {
                var gsaSection = new GsaSection();
                if (gsaSection.FromGwa(newLines[k]) && FindExpDetails(gsaSection, out var comp, out var pde))
                {
                    var structuralProp = new Structural1DPropertyExplicit()
                    {
                        Name          = gsaSection.Name,
                        ApplicationId = gsaSection.ApplicationId,
                        Area          = pde.Area,
                        Iyy           = pde.Iyy,
                        Izz           = pde.Izz,
                        J             = pde.J,
                        Ky            = pde.Ky,
                        Kz            = pde.Kz
                    };

                    //No support for any other material type at this stage
                    if (comp.MaterialType == Section1dMaterialType.CONCRETE || comp.MaterialType == Section1dMaterialType.STEEL)
                    {
                        var materialIndex = comp.MaterialIndex ?? 0;
                        var materialDict  = (comp.MaterialType == Section1dMaterialType.CONCRETE) ? concreteMaterials : steelMaterials;
                        structuralProp.MaterialRef = (materialIndex > 0 && materialDict.ContainsKey(materialIndex)) ? materialDict[materialIndex] : null;
                    }

                    structural1DPropertyExplicits.Add(structuralProp);
                }
            }

            var props = structural1DPropertyExplicits.Select(pe => new GSA1DPropertyExplicit()
            {
                Value = pe
            }).ToList();

            Initialiser.GsaKit.GSASenderObjects.AddRange(props);
            return((props.Count() > 0) ? new SpeckleObject() : new SpeckleNull());
        }
 private static GsaSection ToGsaSectionConcrete(Structural1DPropertyExplicit prop, int materialIndex)
 {
     return(new GsaSection
     {
         Components = new List <GsaSectionComponentBase>()
         {
             CreateSectionComp(Section1dMaterialType.CONCRETE, materialIndex, prop.Area, prop.Iyy, prop.Izz, prop.J, prop.Ky, prop.Kz),
             //If any of the below have no properties being set, it's because they basically contain fixed values at this stage
             new SectionConc(),
             new SectionLink(),
             new SectionCover(),
             new SectionTmpl()
         }
     });
 }
 private static GsaSection ToGsaSectionSteel(Structural1DPropertyExplicit prop, int materialIndex)
 {
     return(new GsaSection
     {
         Components = new List <GsaSectionComponentBase>()
         {
             CreateSectionComp(Section1dMaterialType.STEEL, materialIndex, prop.Area, prop.Iyy, prop.Izz, prop.J, prop.Ky, prop.Kz),
             new SectionSteel()
             {
                 PlasElas = 1,
                 NetGross = 1,
                 Exposed = 1,
                 Beta = 0.4,
                 Locked = false,
                 Type = SectionSteelSectionType.Undefined,
                 Plate = SectionSteelPlateType.Undefined
             }
         }
     });
 }
예제 #6
0
        public static SpeckleObject ToSpeckle(this GsaSection dummyObject)
        {
            var settings         = Initialiser.AppResources.Settings;
            var element1dResults = settings.ResultTypes != null && settings.ResultTypes.Any(rt => rt.ToString().ToLower().Contains("1d"));

            if (settings.TargetLayer == GSATargetLayer.Analysis && settings.StreamSendConfig == StreamContentConfig.TabularResultsOnly && !element1dResults)
            {
                return(new SpeckleNull());
            }

            var kw       = GsaRecord.GetKeyword <GsaSection>();
            var newLines = Initialiser.AppResources.Cache.GetGwaToSerialise(kw);

            int numAdded = 0;

            var structural1DPropertyExplicits = new List <Structural1DPropertyExplicit>();

            var concreteMaterials = Initialiser.GsaKit.GSASenderObjects.Get <GSAMaterialConcrete>().ToDictionary(o => o.GSAId, o => ((StructuralMaterialConcrete)o.SpeckleObject).ApplicationId);
            var steelMaterials    = Initialiser.GsaKit.GSASenderObjects.Get <GSAMaterialSteel>().ToDictionary(o => o.GSAId, o => ((StructuralMaterialSteel)o.SpeckleObject).ApplicationId);

            //Currently only handles explicit 1D properties
            //Filtering out all but explicit properties:
            //1.  First exclude any GWA lines with the exact string "EXP" - make first pass at filtering them out
            //2.  Call FromGwa for all and perform logic check of values of GsaSection (and subclass) instances
            var indicesContainingEXP = newLines.Keys.Where(k => newLines[k].Contains("EXP")).ToList();
            var gsaSectionsExp       = new List <GsaSection>();

            foreach (var i in indicesContainingEXP)
            {
                var obj = Helper.ToSpeckleTryCatch(dummyObject.Keyword, i, () =>
                {
                    var gsaSection = new GsaSection();
                    if (gsaSection.FromGwa(newLines[i]) && FindExpDetails(gsaSection, out var comp, out var pde))
                    {
                        if (string.IsNullOrEmpty(gsaSection.ApplicationId))
                        {
                            gsaSection.ApplicationId = SpeckleStructuralGSA.Helper.FormatApplicationId(kw, i);
                        }
                        var structuralProp = new Structural1DPropertyExplicit()
                        {
                            Name          = gsaSection.Name,
                            ApplicationId = gsaSection.ApplicationId,
                            Area          = pde.Area,
                            Iyy           = pde.Iyy,
                            Izz           = pde.Izz,
                            J             = pde.J,
                            Ky            = pde.Ky,
                            Kz            = pde.Kz
                        };

                        //No support for any other material type at this stage
                        if (comp.MaterialType == Section1dMaterialType.CONCRETE || comp.MaterialType == Section1dMaterialType.STEEL)
                        {
                            var materialIndex          = comp.MaterialIndex ?? 0;
                            var materialDict           = (comp.MaterialType == Section1dMaterialType.CONCRETE) ? concreteMaterials : steelMaterials;
                            structuralProp.MaterialRef = (materialIndex > 0 && materialDict.ContainsKey(materialIndex)) ? materialDict[materialIndex] : null;
                        }
                        return(structuralProp);
                    }
                    return(new SpeckleNull());
                });