Exemple #1
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool go = false;

            Karamba.Models.GH_Model kModel = null;
            bool kOpen = false;

            if (!DA.GetData(1, ref go))
            {
                return;
            }
            if (!DA.GetData(0, ref kModel))
            {
                return;
            }
            DA.GetData(2, ref kOpen);
            if (kOpen)
            {
                KarambaToRFEM.OpenConnection();
                if (go)
                {
                    KarambaToRFEM.CreateModel(kModel.Value);
                }
            }
            else
            {
                if (go)
                {
                    KarambaToRFEM.OpenConnection();
                    KarambaToRFEM.CreateModel(kModel.Value);
                }
                KarambaToRFEM.CloseConnection();
            }
        }
Exemple #2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            bool go = false;

            if (!DA.GetData(0, ref go))
            {
                return;
            }



            if (go)
            {
                IApplication app    = null;
                IModel       rModel = null;

                try
                {
                    //Get active RFEM5 application
                    app = Marshal.GetActiveObject("RFEM5.Application") as IApplication;
                    app.LockLicense();
                    rModel = app.GetActiveModel();
                    IModelData rData = rModel.GetModelData();
                    KarambaToRFEM.printMaterialIDs(rData);
                }


                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    //Release COM object
                    if (app != null)
                    {
                        app.UnlockLicense();
                        app = null;
                    }

                    //Cleans Garbage collector for releasing all COM interfaces and objects
                    System.GC.Collect();
                    System.GC.WaitForPendingFinalizers();
                }
            }
        }