コード例 #1
0
        private List <Dlubal.RFEM5.Node> CreateRfemNodes(List <Point3d> Rh_pt3d)
        {
            // Gets interface to running RFEM application.
            app = Marshal.GetActiveObject("RFEM5.Application") as IApplication;
            // Locks RFEM licence
            //app.LockLicense();

            // Gets interface to active RFEM model.
            //model = app.GetActiveModel();

            // Gets interface to model data.
            //IModelData data = model.GetModelData();

            //List<Dlubal.RFEM5.Node> RfemNodeList = new List<Dlubal.RFEM5.Node>();
            Dlubal.RFEM5.Node[] RfemNodeArray = new Dlubal.RFEM5.Node[Rh_pt3d.Count];


            try
            {
                // modification
                // Sets all objects to model data.
                // data.PrepareModification();

                for (int index = 0; index < Rh_pt3d.Count; index++)

                {
                    //Dlubal.RFEM5.Node RfemNode = new Dlubal.RFEM5.Node();
                    // Node RfemNode = new Node();
                    RfemNodeArray[index].No = index + 1;
                    RfemNodeArray[index].X  = Rh_pt3d[index].X;
                    RfemNodeArray[index].Y  = Rh_pt3d[index].Y;
                    RfemNodeArray[index].Z  = Rh_pt3d[index].Z;


                    //data.SetNode(RfemNodeArray[index]);
                }

                //modification
                //data.FinishModification();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            // Releases interface to RFEM model.
            model = null;

            // Unlocks licence and releases interface to RFEM application.
            if (app != null)
            {
                //app.UnlockLicense();
                app = null;
            }

            // Cleans Garbage Collector and releases all cached COM interfaces.
            System.GC.Collect();
            System.GC.WaitForPendingFinalizers();

            List <Dlubal.RFEM5.Node> RfemNodeList        = RfemNodeArray.OfType <Dlubal.RFEM5.Node>().ToList(); // this isn't going to be fast.
            List <RfemNodeType>      RfemNodeGHParamList = new List <RfemNodeType>();

            // List<RfemNodeType> aaaa = new List<RfemNodeType>();

            foreach (Dlubal.RFEM5.Node rfemNode in RfemNodeList)
            {
                RfemNodeType rfemNodeWrapper = new RfemNodeType(rfemNode);
                RfemNodeGHParamList.Add(rfemNodeWrapper);
            }

            return(RfemNodeList);
        }