Exemple #1
0
        public ETABSAdapter(string filePath = "", EtabsSettings etabsSetting = null, bool active = false)
#endif
        {
            //Initialisation
            BH.Adapter.Modules.Structure.ModuleLoader.LoadModules(this);
            SetupDependencies();
            SetupComparers();
            AdapterIdFragmentType = typeof(ETABSId);

            if (active)
            {
                this.EtabsSettings = etabsSetting == null ? new EtabsSettings() : etabsSetting;

#if Debug16 || Release16
                string pathToETABS = @"C:\Program Files\Computers and Structures\ETABS 2016\ETABS.exe";
#elif Debug17 || Release17
                string pathToETABS = @"C:\Program Files\Computers and Structures\ETABS 17\ETABS.exe";
#endif


                cHelper helper    = new Helper();
                string  programId = "CSI.ETABS.API.ETABSObject";


                int processes = System.Diagnostics.Process.GetProcessesByName("ETABS").Length;

                if (processes > 1)
                {
                    Engine.Base.Compute.RecordWarning("More than one ETABS instance is open. BHoM has attached to the most recently updated process, " +
                                                      "but you should only work with one ETABS instance at a time with BHoM.");
                }

                if (processes > 0)
                {
                    object runningInstance = System.Runtime.InteropServices.Marshal.GetActiveObject(programId);

                    m_app   = (cOAPI)runningInstance;
                    m_model = m_app.SapModel;
                    if (System.IO.File.Exists(filePath))
                    {
                        m_model.File.OpenFile(filePath);
                    }
                    m_model.SetPresentUnits(eUnits.N_m_C);
                }
                else
                {
#if Debug16 || Release16 || Debug17 || Release17
                    m_app = helper.CreateObject(pathToETABS);
#else
                    m_app = helper.CreateObjectProgID(programId); //Starts the latest installed version of ETABS
#endif
                    m_app.ApplicationStart();
                    m_model = m_app.SapModel;
                    m_model.InitializeNewModel(eUnits.N_m_C);
                    if (System.IO.File.Exists(filePath))
                    {
                        m_model.File.OpenFile(filePath);
                    }
                    else
                    {
                        m_model.File.NewBlank();
                    }
                }

                LoadSectionDatabaseNames();
            }
        }
Exemple #2
0
 public ETABS17Adapter(string filePath = "", EtabsSettings etabsSetting = null, bool active = false)