示例#1
0
        public static Dictionary <string, object> SAPModel(bool read)
        {
            if (read)
            {
                StructuralModel Model = new StructuralModel();

                cSapModel mySapModel = null;
                string    modelunits = string.Empty;

                // Open & instantiate SAP file
                Initialize.GrabOpenSAP(ref mySapModel, ref modelunits, "");

                StructuralModelFromSapFile(ref mySapModel, ref Model, modelunits);

                // Return outputs
                return(new Dictionary <string, object>
                {
                    { "StructuralModel", Model },
                    { "units", modelunits }
                });
            }
            else
            {
                throw new Exception("Set boolean True to read!");
            }
        }
示例#2
0
        public static Dictionary <string, object> SAPModel(string FilePath, bool read)
        {
            if (read)
            {
                StructuralModel Model = new StructuralModel();
                Model.StructuralElements = new List <Element>();
                cSapModel mySapModel = null;
                string    units      = string.Empty;
                // Open & instantiate SAP file
                Initialize.OpenSAPModel(FilePath, ref mySapModel, ref units);

                // Populate the model's elemets
                StructuralModelFromSapFile(ref mySapModel, ref Model, units);

                // Return outputs
                return(new Dictionary <string, object>
                {
                    { "StructuralModel", Model },
                    { "units", units }
                });
            }
            else
            {
                throw new Exception("Set boolean True to read!");
            }
        }
示例#3
0
        public static Dictionary <string, object> ToSAP(StructuralModel StructuralModel, bool Bake, string Units = "kip_ft_F", bool Delete = true)
        {
            if (Bake)
            {
                // 1. Calculate Lenght Conversion Factor
                string     fromUnit = "m"; // Dynamo API Units
                LengthUnit LU       = new LengthUnit();
                //LengthUnit LU= DynamoUnits.Length.LengthUnit; // Display Units

                //double LengthSF = SAPConnection.Utilities.UnitConversion(Units, fromUnit); // Lenght Conversion Factor
                double LengthSF = 1;
                // Clear Frame & Area Dictionaries to hold
                SAPFrmList.Clear();
                SAPAreaList.Clear();
                SAPJointList.Clear();
                report.Clear();

                // 2. Create new SAP Model and bake Stuctural Model
                if (StructuralModel != null)
                {
                    CreateorUpdateSAPModel(ref StructuralModel, Units, LengthSF, Delete);
                }
            }
            else
            {
                throw new Exception("Node not run. Please, set boolean to true");
            }
            //return StructuralModel;

            return(new Dictionary <string, object>
            {
                { "Structural Model", StructuralModel },
                { "Report", report }
            });
        }
示例#4
0
        /// <summary>
        /// Collects Structural Elements into a Structural Model
        /// </summary>
        /// <param name="StructuralElements">Structural elements in the project. Please, input as a flat list</param>
        /// <returns>Structural Model consisting of the structural elements provided</returns>
        public static StructuralModel Collector(List <Element> StructuralElements)
        {
            CheckDuplicates(StructuralElements);
            StructuralModel mySt = new StructuralModel();

            mySt.StructuralElements = StructuralElements;
            return(mySt);
        }
示例#5
0
        internal static void StructuralModelFromSapFile(ref cSapModel SapModel, ref StructuralModel model, string SapModelUnits)
        {
            model.StructuralElements = new List <Element>();
            model.ModelDefinitions   = new List <Definition>();

            List <LoadPattern> TempLPatterns = new List <LoadPattern>();

            string error = string.Empty;

            if (SapModel != null)
            {
                // 1.a GET LOAD PATTERNS

                string[] LoadPatternNames       = null;
                string[] LoadPatternTypes       = null;
                double[] LoadPatternMultipliers = null;

                StructureMapper.GetLoadPatterns(ref SapModel, ref LoadPatternNames, ref LoadPatternTypes, ref LoadPatternMultipliers);
                if (LoadPatternNames != null)
                {
                    foreach (string lpname in LoadPatternNames)
                    {
                        int         pos = Array.IndexOf(LoadPatternNames, lpname);
                        LoadPattern lp  = new LoadPattern(lpname, LoadPatternTypes[pos], LoadPatternMultipliers[pos]);
                        model.ModelDefinitions.Add(lp);
                        TempLPatterns.Add(lp);
                    }
                }

                // 1.b GET LOAD CASES

                string[] LoadCasesNames       = null;
                string[] LoadCasesTypes       = null;
                double[] LoadCasesMultipliers = null;

                //With this method we only get the name and the type of each load case
                StructureMapper.GetLoadCases(ref SapModel, ref LoadCasesNames, ref LoadCasesMultipliers, ref LoadCasesTypes);
                if (LoadCasesNames != null)
                {
                    foreach (string lcname in LoadCasesNames)
                    {
                        int pos = Array.IndexOf(LoadCasesNames, lcname);

                        //create a new load
                        LoadCase lc = new LoadCase();
                        lc.name = lcname;
                        lc.type = LoadCasesTypes[pos];

                        model.ModelDefinitions.Add(lc);
                    }
                }

                //1.c GET LOAD COMBOS

                string[]   LoadCombosNames       = null;
                string[][] LoadCombosTypes       = null;
                string[][] LoadCombosCases       = null;
                string[][] LoadCombosDefinitions = null;
                double[][] LoadCombosMultipliers = null;



                StructureMapper.GetLoadCombos(ref SapModel, ref LoadCombosNames, ref LoadCombosTypes, ref LoadCombosCases, ref LoadCombosMultipliers, ref LoadCombosDefinitions);

                if (LoadCombosNames != null)
                {
                    foreach (string lcname in LoadCombosNames)
                    {
                        int pos = Array.IndexOf(LoadCombosNames, lcname);

                        List <Definition> LoadDefinitions = new List <Definition>();

                        foreach (string comboType in LoadCombosTypes[pos])
                        {
                            int        pos2 = Array.IndexOf(LoadCombosTypes[pos], comboType);
                            Definition def  = new Definition();
                            if (comboType == "LoadCase")
                            {
                                //find the existing Load Case
                                foreach (Definition d in model.ModelDefinitions)
                                {
                                    if (d.Type == Definitions.Type.LoadCase)
                                    {
                                        if (((LoadCase)d).name == LoadCombosDefinitions[pos][pos2])
                                        {
                                            def = d;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                def.Type = Definitions.Type.LoadCombo;
                                ((LoadCombo)def).name = comboType;
                            }

                            LoadDefinitions.Add(def);
                        }

                        //create a new load combo
                        LoadCombo loadcombo = new LoadCombo(lcname, LoadCombosTypes[pos][0], LoadDefinitions, LoadCombosMultipliers[pos].ToList());

                        model.ModelDefinitions.Add(loadcombo);
                    }
                }



                // 2. GET DYNAMO FRAMES ( get Loads and Releases that are assigned to that frame)
                //2.a GET LOADS that are Assigned to Frames

                Dictionary <int, string> DictFrm_PointLoads = new Dictionary <int, string>();
                Dictionary <int, string> DictFrm_DistLoads  = new Dictionary <int, string>();

                //Get Point Loads
                string[] framesWithPointLoads = null;
                string[] PlPattern            = null;
                int      Pnumber  = 0;
                int[]    PmyType  = null;
                string[] PCsys    = null;
                int[]    Pdir     = null;
                double[] PRelDist = null;
                double[] PDist    = null;
                double[] PVal     = null;

                LoadMapper.GetPointLoads(ref SapModel, ref framesWithPointLoads, ref Pnumber, ref PlPattern, ref PmyType, ref PCsys, ref Pdir, ref PRelDist, ref PDist, ref PVal);
                if (framesWithPointLoads != null)
                {
                    for (int i = 0; i < framesWithPointLoads.Count(); i++)
                    {
                        DictFrm_PointLoads.Add(i, framesWithPointLoads[i]);
                    }
                }

                // Get Distributed Loads
                string[] framesWithDistributedLoads = null;
                string[] DlPattern = null;
                int      Dnumber   = 0;
                int[]    DmyType   = null;
                string[] DCsys     = null;
                int[]    Ddir      = null;
                double[] DRD1      = null;
                double[] DRD2      = null;
                double[] DDist1    = null;
                double[] DDist2    = null;
                double[] DVal1     = null;
                double[] DVal2     = null;

                LoadMapper.GetDistributedLoads(ref SapModel, ref framesWithDistributedLoads, ref Dnumber, ref DlPattern, ref DmyType, ref DCsys, ref Ddir, ref DRD1, ref DRD2, ref DDist1, ref DDist2, ref DVal1, ref DVal2);
                if (framesWithDistributedLoads != null)
                {
                    for (int i = 0; i < framesWithDistributedLoads.Count(); i++)
                    {
                        DictFrm_DistLoads.Add(i, framesWithDistributedLoads[i]);
                    }
                }


                //2.b Get Frames

                // Calculate Length Scale Factor
                //Double SF = Utilities.UnitConversion("m", SapModelUnits); // Dynamo API Lenght Unit is 'meter'
                Double SF = 1;

                List <string> FrmIds = new List <string>();
                StructureMapper.GetSAPFrameList(ref SapModel, ref FrmIds);

                for (int i = 0; i < FrmIds.Count; i++)
                {
                    Point  s          = null;
                    Point  e          = null;
                    string matProp    = "A992Fy50";     // default value
                    string secName    = "W12X14";       // default value
                    string secCatalog = "AISC14";       // default value
                    string Just       = "MiddleCenter"; // default value
                    double Rot        = 0;              // default value

                    StructureMapper.GetFrm(ref SapModel, FrmIds[i], ref s, ref e, ref matProp, ref secName, ref Just, ref Rot, ref secCatalog, SF);
                    SectionProp secProp = new SectionProp(secName, matProp, secCatalog);
                    Frame       d_frm   = new Frame(s, e, secProp, Just, Rot);
                    d_frm.Label = FrmIds[i];
                    model.StructuralElements.Add(d_frm);

                    //LOADS
                    // Frame might have multiple loads assigned to it...
                    d_frm.Loads = new List <Load>();

                    //Check if the frame has distributed loads
                    var outindexes = from obj in DictFrm_DistLoads
                                     where obj.Value == d_frm.Label
                                     select obj.Key;

                    foreach (int index in outindexes)
                    {
                        LoadPattern Dlp = null;
                        foreach (LoadPattern loadp in TempLPatterns)
                        {
                            if (loadp.name == DlPattern[index])
                            {
                                Dlp = loadp;
                                break;
                            }
                        }
                        if (Dlp != null)
                        {
                            // using relDist as true, and using the relative distance values DRD1 and DRD2
                            bool relDist = true;
                            Load l       = new Load(Dlp, DmyType[index], Ddir[index], DRD1[index], DRD2[index], DVal1[index], DVal2[index], DCsys[index], relDist);
                            l.LoadType = "DistributedLoad";
                            d_frm.Loads.Add(l);
                        }
                    }

                    //Check if the frame has Point Loads
                    var outindexesO = from obj in DictFrm_PointLoads
                                      where obj.Value == d_frm.Label
                                      select obj.Key;

                    foreach (int index in outindexesO)
                    {
                        LoadPattern Plp = null;
                        foreach (LoadPattern loadp in TempLPatterns)
                        {
                            if (loadp.name == PlPattern[index])
                            {
                                Plp = loadp;
                                break;
                            }
                        }

                        if (Plp != null)
                        {
                            bool relativedist = true;
                            Load l            = new Load(Plp, PmyType[index], Pdir[index], PRelDist[index], PVal[index], PCsys[index], relativedist);
                            l.LoadType = "PointLoad";
                            d_frm.Loads.Add(l);
                        }
                    }

                    //RELEASES
                    bool[] ii = new bool[6];
                    bool[] jj = new bool[6];
                    ReleaseMapper.Get(ref SapModel, FrmIds[i], ref ii, ref jj);

                    // Populate if return releases
                    if (ii.Contains(true) || jj.Contains(true))
                    {
                        d_frm.Releases = Release.Set(ii[0], jj[0]
                                                     , ii[1], jj[1]
                                                     , ii[2], jj[2]
                                                     , ii[3], jj[3]
                                                     , ii[4], jj[4]
                                                     , ii[5], jj[5]);
                    }
                }

                // 2.b Get Shells from SAP Model
                List <string> AreaIds = new List <string>();
                SAPConnection.StructureMapper.GetSAPAreaList(ref SapModel, ref AreaIds);

                for (int i = 0; i < AreaIds.Count; i++)
                {
                    Surface S = null;

                    string propName = string.Empty;
                    SAPConnection.StructureMapper.GetShell(ref SapModel, AreaIds[i], ref S, SF, ref propName);

                    int    ShellType = 1;
                    bool   DOF       = true;
                    string MatProp   = string.Empty;
                    double MatAngle  = 0;
                    double Thickness = 0;
                    double Bending   = 0;
                    SAPConnection.StructureMapper.GetShellProp(ref SapModel, propName, ref ShellType, ref DOF, ref MatProp, ref MatAngle, ref Thickness, ref Bending);
                    ShellProp sP = new ShellProp(propName, ShellType, DOF, MatProp, MatAngle, Thickness * SF, Bending);

                    Shell d_Shell = new Shell(S, sP);
                    d_Shell.Label = AreaIds[i];
                    model.StructuralElements.Add(d_Shell);
                }

                // 3. GET RESTRAINTS
                int CountRes = RestraintMapper.Count(ref SapModel);
                if (CountRes > 0)
                {
                    List <string> PtIds = new List <string>();
                    RestraintMapper.GetSupportedPts(ref SapModel, ref PtIds);

                    // Populate Dynamo Restraints
                    foreach (var PtId in PtIds)
                    {
                        Point  Pti        = null;
                        bool[] restraints = new bool[6];

                        RestraintMapper.Get(ref SapModel, PtId, ref Pti, ref restraints, SF);

                        Joint myj = new Joint(Pti);
                        myj.Label = PtId;

                        // Populate on Joint Restraints
                        Restraint support = Restraint.Define(restraints[0], restraints[1], restraints[2], restraints[3], restraints[4], restraints[5]);

                        myj.JointRestraint = support;

                        model.StructuralElements.Add(myj);
                    }
                }
            }
            else
            {
                throw new Exception("Make sure SAP Model is open!");
            }


            // Get Groups
            List <String> SapGroups = new List <string>();

            SAPConnection.GroupMapper.GetSAPGroupList(ref SapModel, ref SapGroups);

            int counter = 0;

            foreach (var g in SapGroups)
            {
                Group myG = new Group();
                myG.Name          = g;
                myG.GroupElements = new List <Element>();

                // get assignments
                int[]    types  = null;
                string[] Labels = null;
                SAPConnection.GroupMapper.GetGroupAssignments(ref SapModel, g, ref types, ref Labels);

                if (Labels != null && Labels.Count() > 0)
                {
                    for (int i = 0; i < Labels.Length; i++)
                    {
                        if (types[i] == 1) // Joint
                        {
                            try
                            {
                                var gel = (from el in model.StructuralElements
                                           where el.Label == Labels[i] && el.Type == Structure.Type.Joint
                                           select el).First();
                                if (gel != null)
                                {
                                    myG.GroupElements.Add(gel);
                                }
                            }
                            catch (Exception) { }
                        }
                        else if (types[i] == 2) // frame
                        {
                            try
                            {
                                var gel = (from el in model.StructuralElements
                                           where el.Type == Structure.Type.Frame && el.Label == Labels[i]
                                           select el).First();
                                if (gel != null)
                                {
                                    myG.GroupElements.Add(gel);
                                }
                            }
                            catch (Exception) { }
                        }
                        else if (types[i] == 3) // cable
                        {
                            //TODO: After cable object defined
                        }
                        else if (types[i] == 5) // shell
                        {
                            var gel = (from el in model.StructuralElements
                                       where el.Type == Structure.Type.Shell && el.Label == Labels[i]
                                       select el).First();
                            if (gel != null)
                            {
                                myG.GroupElements.Add(gel);
                            }
                        }
                    }
                }
                else
                {
                    counter++;
                }

                //Add to Model definitions
                model.ModelDefinitions.Add(myG);
            }
            if (counter == SapGroups.Count)
            {
                //throw new Exception("The group(s) have no members assigned");
            }
        }
示例#6
0
        // Create or Update Sap Model from a Dynamo Model
        private static void CreateorUpdateSAPModel(ref StructuralModel StructuralModel, string Units, double SF, bool delete)
        {
            string error = string.Empty;

            //1. INSTANTIATE NEW OR GRAB OPEN SAPMODEL

            // check if any SAP file is open, grab
            SAP2000v16.SapObject mySapObject = null;
            string ModelUnits = string.Empty;

            // Open & instantiate SAP file
            Initialize.GrabOpenSAP(ref mySapModel, ref ModelUnits, Units);

            if (mySapModel == null)
            {
                // Open a blank SAP Model
                try
                {
                    SAPConnection.Initialize.InitializeSapModel(ref mySapObject, ref mySapModel, Units);
                }
                catch (Exception)
                {
                    SAPConnection.Initialize.Release(ref mySapObject, ref mySapModel);
                };
            }

            //2. Create or Update Frames (Sets Releases)
            // 2.a. Harvest the elements from SAP Model
            SAPConnection.StructureMapper.GetSAPFrameList(ref mySapModel, ref SAPFrmList);   // frms
            SAPConnection.StructureMapper.GetSAPAreaList(ref mySapModel, ref SAPAreaList);   // areas
            SAPConnection.StructureMapper.GetSAPJointList(ref mySapModel, ref SAPJointList); // joints

            // 2a. DELETE
            if (delete)
            {
                //Delete Frms from SAP not in Structural elements
                foreach (var sapfrm in SAPFrmList)
                {
                    Element el = null;
                    try
                    {
                        el = (from f in StructuralModel.StructuralElements
                              where f.Label == sapfrm && f.Type == Structure.Type.Frame
                              select f).First();
                    }
                    catch (Exception) { }

                    if (el == null) // not in Dynamo Structure so delete from SAP Model
                    {
                        SAPConnection.StructureMapper.DeleteFrm(ref mySapModel, sapfrm);
                    }
                }

                // Delete Areas from SAP not in Structural elements
                foreach (var sapArea in SAPAreaList)
                {
                    //Element el = null;
                    //try
                    //{
                    //    el = (from f in StructuralModel.StructuralElements
                    //          where f.Label == sapArea
                    //          select f).First();
                    //}
                    //catch (Exception) { }

                    //if (el == null)
                    //{
                    SAPConnection.StructureMapper.DeleteArea(ref mySapModel, sapArea, ref error);
                    if (error != string.Empty)
                    {
                        report.Add(error);
                        error = string.Empty;
                    }
                    //}
                }

                // Delete Joints from SAP not in Structural elements
                foreach (var sapJoint in SAPJointList)
                {
                    Element el = null;
                    try
                    {
                        el = (from f in StructuralModel.StructuralElements
                              where f.Label == sapJoint && f.Type == Structure.Type.Joint
                              select f).First();
                    }
                    catch (Exception) { }

                    if (el == null && sapJoint.StartsWith("dyn")) // not in Dynamo Structure so delete from SAP Model
                    {
                        SAPConnection.StructureMapper.DeleteJoint(ref mySapModel, sapJoint, ref error);
                        if (error != string.Empty)
                        {
                            report.Add(error);
                            error = string.Empty;
                        }
                    }
                }
            }


            //2. CREATE OR UPDATE SIMULTENOUSLY
            //2.b. Create or Update
            foreach (var el in StructuralModel.StructuralElements)
            {
                if (el.Type == Structure.Type.Frame)
                {
                    bool isupdate = SAPFrmList.Contains(el.Label);

                    CreateorUpdateFrame(el as Frame, ref mySapModel, SF, isupdate);

                    Frame frm = el as Frame;
                    // Set Releases
                    if (frm.Releases != null)
                    {
                        SetReleases(el as Frame, ref mySapModel); // Set releases
                    }
                }
                else if (el.Type == Structure.Type.Shell)
                {
                    bool isupdate = SAPAreaList.Contains(el.Label);

                    CreateorUpdateArea(el as Shell, ref mySapModel, SF, false);
                }
                else if (el.Type == Structure.Type.Joint)
                {
                    bool isupdate = SAPJointList.Contains(el.Label);
                    CreateorUpdateJoint(el as Joint, ref mySapModel, SF, isupdate);
                }
            }

            // LinqInquiry
            List <Definition> LPatterns = new List <Definition>();

            try
            {
                LPatterns = (from def in StructuralModel.ModelDefinitions
                             where def.Type == Definitions.Type.LoadPattern
                             select def).ToList();
            }
            catch (Exception)
            {
            }
            // Add Load Patterns to the SAP Model
            if (LPatterns.Count > 0)
            {
                foreach (LoadPattern lp in LPatterns)
                {
                    //Call the AddLoadPattern method
                    SAPConnection.LoadMapper.AddLoadPattern(ref mySapModel, lp.name, lp.type, lp.multiplier);
                }
            }

            List <Definition> LCases = new List <Definition>();

            try
            {
                LCases = (from def in StructuralModel.ModelDefinitions
                          where def.Type == Definitions.Type.LoadCase
                          select def).ToList();
            }
            catch { }

            if (LCases.Count > 0)
            {
                foreach (LoadCase lc in LCases)
                {
                    List <string> types = new List <string>();
                    List <string> names = new List <string>();
                    List <double> SFs   = new List <double>();

                    for (int i = 0; i < lc.loadPatterns.Count; i++)
                    {
                        types.Add("Load");
                        names.Add(lc.loadPatterns[i].name);
                        SFs.Add(lc.sFs[i]);
                    }

                    string[] Dtypes = types.ToArray();
                    string[] Dnames = names.ToArray();
                    double[] DSFs   = SFs.ToArray();

                    SAPConnection.LoadMapper.AddLoadCase(ref mySapModel, lc.name, types.Count(), ref Dtypes, ref Dnames, ref DSFs, lc.type);
                }
            }



            List <Definition> LCombo = new List <Definition>();

            try
            {
                LCombo = (from def in StructuralModel.ModelDefinitions
                          where def.Type == Definitions.Type.LoadCombo
                          select def).ToList();
            }
            catch { }

            if (LCombo.Count > 0)
            {
                foreach (LoadCombo lc in LCombo)
                {
                    List <string> types = new List <string>();
                    List <string> names = new List <string>();
                    List <double> SFs   = new List <double>();

                    for (int i = 0; i < lc.loadDefinitions.Count; i++)
                    {
                        if (lc.loadDefinitions[i].Type == Definitions.Type.LoadCase)
                        {
                            types.Add("LoadCase");
                            names.Add(((LoadCase)lc.loadDefinitions[i]).name);
                        }
                        else if (lc.loadDefinitions[i].Type == Definitions.Type.LoadCombo)
                        {
                            types.Add("LoadCombo");
                            names.Add(((LoadCombo)lc.loadDefinitions[i]).name);
                        }
                        SFs.Add(lc.sFs[i]);
                    }


                    string[] Dtypes = types.ToArray();
                    string[] Dnames = names.ToArray();
                    double[] DSFs   = SFs.ToArray();

                    SAPConnection.LoadMapper.AddLoadCombo(ref mySapModel, lc.name, Dtypes, Dnames, DSFs, lc.type);
                }
            }

            // Set Loads
            foreach (var el in StructuralModel.StructuralElements)
            {
                if (el.Type == Structure.Type.Frame)
                {
                    Frame frm = el as Frame;

                    // Set Loads
                    if (frm.Loads != null)
                    {
                        SetLoads(el as Frame, ref mySapModel);
                    }
                }
            }

            // Create or Update Groups
            // Harvest the names of the groups// delete the ones not in the SAP Model
            SAPConnection.GroupMapper.GetSAPGroupList(ref mySapModel, ref SAPGroupList);

            List <Definition> Groups = new List <Definition>();

            try
            {
                Groups = (from def in StructuralModel.ModelDefinitions
                          where def.Type == Definitions.Type.Group
                          select def).ToList();
            }
            catch (Exception)
            {
            }

            // Update or Create new one and set assignments
            List <string> tempNames = new List <string>();

            if (Groups.Count > 0)
            {
                foreach (Group g in Groups)
                {
                    tempNames.Add(g.Name);

                    bool update = false;
                    if (SAPGroupList.Contains(g.Name))
                    {
                        update = true;
                    }

                    CreateorUpdateGroup(g, ref mySapModel, update);
                }
            }

            if (delete)
            {
                foreach (var g in SAPGroupList)
                {
                    // Delete from SAP Model
                    if (!tempNames.Contains(g))
                    {
                        SAPConnection.GroupMapper.Delete(ref mySapModel, g);
                    }
                }
            }



            // refresh View
            //SAPConnection.StructureMapper.RefreshView(ref mySapModel);

            // Delete unconnected points at the SAP
            SAPConnection.StructureMapper.DeleteUnconnectedPts(ref mySapModel);

            // refresh View
            SAPConnection.StructureMapper.RefreshView(ref mySapModel);

            //if can't set to null, will be a hanging process
            mySapModel  = null;
            mySapObject = null;
        }
示例#7
0
        public static Dictionary <string, object> Decompose(StructuralModel structuralModel)
        {
            List <Element> Frms   = new List <Element>();
            List <Element> Shells = new List <Element>();
            List <Element> Joints = new List <Element>();

            if (structuralModel.StructuralElements != null && structuralModel.StructuralElements.Count > 0)
            {
                foreach (var el in structuralModel.StructuralElements)
                {
                    if (el.Type == Structure.Type.Frame)
                    {
                        Frms.Add(el);
                    }
                    else if (el.Type == Structure.Type.Shell)
                    {
                        Shells.Add(el);
                    }
                    else if (el.Type == Structure.Type.Joint)
                    {
                        Joints.Add(el);
                    }
                }
            }

            List <Definition> LoadPatterns = new List <Definition>();
            List <Definition> LoadCases    = new List <Definition>();
            List <Definition> LoadCombos   = new List <Definition>();
            List <Definition> Groups       = new List <Definition>();

            if (structuralModel.ModelDefinitions != null && structuralModel.ModelDefinitions.Count > 0)
            {
                foreach (var def in structuralModel.ModelDefinitions)
                {
                    if (def.Type == Definitions.Type.LoadCase)
                    {
                        LoadCases.Add(def);
                    }
                    else if (def.Type == Definitions.Type.LoadPattern)
                    {
                        LoadPatterns.Add(def);
                    }
                    else if (def.Type == Definitions.Type.Group)
                    {
                        Groups.Add(def);
                    }
                    else if (def.Type == Definitions.Type.LoadCombo)
                    {
                        LoadCombos.Add(def);
                    }
                }
            }

            //Return outputs
            return(new Dictionary <string, object>
            {
                { "Frames", Frms },
                { "Shells", Shells },
                { "Joints", Joints },
                { "Load Patterns", LoadPatterns },
                { "Load Cases", LoadCases },
                { "Load Combos", LoadCombos },
                { "Groups", Groups }
            });
        }