コード例 #1
0
ファイル: UniformLoadSet.cs プロジェクト: BHoM/RAM_Toolkit
        /***************************************************/
        /**** Private methods                           ****/
        /***************************************************/

        private List <UniformLoadSet> ReadUniformLoadSets(List <string> ids = null)
        {
            List <UniformLoadSet> bhomUniformLoadSets = new List <UniformLoadSet>();

            ISurfaceLoadPropertySets RAMLoadSets = m_Model.GetSurfaceLoadPropertySets();

            for (int i = 0; i < RAMLoadSets.GetCount(); i++)
            {
                UniformLoadSet bhLoad = RAMLoadSets.GetAt(i).ToBHoMObject();
                bhomUniformLoadSets.Add(bhLoad);
            }

            return(bhomUniformLoadSets);
        }
コード例 #2
0
ファイル: UniformLoadSet.cs プロジェクト: BHoM/RAM_Toolkit
        /***************************************************/
        /**** Private methods                           ****/
        /***************************************************/

        private bool CreateCollection(IEnumerable <UniformLoadSet> loadSets)
        {
            foreach (UniformLoadSet loadSet in loadSets)
            {
                try
                {
                    ISurfaceLoadPropertySets ramSurfaceLoadPropertySets = m_Model.GetSurfaceLoadPropertySets();

                    int existingLoadPropSetID = 0;

                    //Check if load set already exists
                    for (int i = 0; i < ramSurfaceLoadPropertySets.GetCount(); i++)
                    {
                        ISurfaceLoadPropertySet ramPropSet = ramSurfaceLoadPropertySets.GetAt(i);
                        if (ramPropSet.strLabel == loadSet.Name)
                        {
                            existingLoadPropSetID = ramPropSet.lUID;
                        }
                    }

                    if (existingLoadPropSetID == 0)
                    {
                        //Add the loadset if it does not already exist
                        ISurfaceLoadPropertySet ramLoadSet = ramSurfaceLoadPropertySets.Add(loadSet.Name);

                        int liveCount = 0;

                        foreach (UniformLoadSetRecord loadRecord in loadSet.Loads)
                        {
                            switch (loadRecord.Name)
                            {
                            case "ConstructionDeadLCa":
                                ramLoadSet.dConstDeadLoad = loadRecord.Load.ToKilopoundForcePerSquareInch();
                                break;

                            case "ConstructionLiveLCa":
                                ramLoadSet.dConstLiveLoad = loadRecord.Load.ToKilopoundForcePerSquareInch();
                                break;

                            case "DeadLCa":
                                ramLoadSet.dDeadLoad = loadRecord.Load.ToKilopoundForcePerSquareInch();
                                break;

                            case "MassDeadLCa":
                                ramLoadSet.dMassDeadLoad = loadRecord.Load.ToKilopoundForcePerSquareInch();
                                break;

                            case "PartitionLCa":
                                ramLoadSet.dPartitionLoad = loadRecord.Load.ToKilopoundForcePerSquareInch();
                                break;

                            case "LiveLCa":
                                ramLoadSet.eLiveLoadType = ELoadCaseType.LiveReducibleLCa;
                                ramLoadSet.dLiveLoad     = loadRecord.Load.ToKilopoundForcePerSquareInch();
                                liveCount++;
                                break;

                            case "LiveStorageLCa":
                                ramLoadSet.eLiveLoadType = ELoadCaseType.LiveStorageLCa;
                                ramLoadSet.dLiveLoad     = loadRecord.Load.ToKilopoundForcePerSquareInch();
                                liveCount++;
                                break;

                            case "LiveUnReducibleLCa":
                                ramLoadSet.eLiveLoadType = ELoadCaseType.LiveUnReducibleLCa;
                                ramLoadSet.dLiveLoad     = loadRecord.Load.ToKilopoundForcePerSquareInch();
                                liveCount++;
                                break;

                            case "LiveRoofLCa":
                                ramLoadSet.eLiveLoadType = ELoadCaseType.LiveRoofLCa;
                                ramLoadSet.dLiveLoad     = loadRecord.Load.ToKilopoundForcePerSquareInch();
                                liveCount++;
                                break;

                            default:
                                Engine.Base.Compute.RecordWarning($"the record {loadRecord.Name} in {loadSet.Name} was not recognized. Create your UniformLoadSet using CreateRAMUniformLoadSet() in the RAM toolkit!");
                                break;
                            }
                        }
                        ;

                        if (liveCount > 1)
                        {
                            Engine.Base.Compute.RecordWarning("More than one live load has been set; only the last one will be applied");
                        }

                        //Set the custom data to return if created
                        RAMId RAMId = new RAMId();
                        RAMId.Id = ramLoadSet.lUID;
                        loadSet.SetAdapterId(RAMId);
                    }
                    else
                    {
                        //Set the custom data to return if already existing
                        RAMId RAMId = new RAMId();
                        RAMId.Id = existingLoadPropSetID;
                        loadSet.SetAdapterId(RAMId);
                    }
                }
                catch
                {
                    CreateElementError("UniformLoadSet", loadSet.Name);
                }
            }

            //Save file
            m_IDBIO.SaveDatabase();

            return(true);
        }