public static void CreateModel(Karamba.Models.Model kModel)
        {
            if (RModel != null)
            {
                Node[]         rNodes         = Nodes(kModel.nodes);
                NodalSupport[] rSupports      = Supports(kModel.supports);
                Material[]     rMaterials     = Materials(kModel.materials);
                CrossSection[] rCrossSections = CrossSections(kModel.crosecs, kModel);
                Tuple <Member[], Dlubal.RFEM5.Line[]> vali = Members(kModel.elems);
                Member[]            rMembers      = vali.Item1;
                Dlubal.RFEM5.Line[] rLines        = vali.Item2;
                LoadCase[]          lCases        = LoadCases(kModel);
                MemberLoad[]        rMemberLoads  = MemberLoads(kModel.eloads);
                NodalLoad[]         rNodalLoads   = NodalLoads(kModel.ploads);
                MemberHinge[]       rMemberHinges = MemberHinges(kModel.joints);

                //Get active RFEM5 application
                try
                {
                    IModelData rData  = RModel.GetModelData();
                    ILoads     rLoads = RModel.GetLoads();

                    //Cleans the model and load data data
                    rData.PrepareModification();
                    rData.Clean();
                    rData.FinishModification();

                    rLoads.PrepareModification();
                    rLoads.Clean();
                    rLoads.FinishModification();

                    //Model elements
                    rData.PrepareModification();

                    rData.SetNodes(rNodes);
                    rData.SetNodalSupports(rSupports);
                    rData.SetMaterials(rMaterials);
                    rData.SetCrossSections(rCrossSections);
                    rData.SetMemberHinges(rMemberHinges);
                    rData.SetLines(rLines);
                    rData.SetMembers(rMembers);

                    rData.FinishModification();

                    //Load cases
                    rLoads.PrepareModification();
                    rLoads.SetLoadCases(lCases);
                    rLoads.FinishModification();

                    //Loads
                    setRFEMmemberLoads(rLoads, rMemberLoads);
                    setRFEMnodalLoads(rLoads, rNodalLoads);
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #2
0
        private void duStuff(ILoads rLoads, double mult, int i, ref ErrorInfo[] err, ref ICalculation calc)
        {
            ILoadCase          lCase = rLoads.GetLoadCase(1, ItemAt.AtNo);
            AnalysisParameters param = new AnalysisParameters();

            param.ModifyLoadingByFactor = true;
            param.LoadingFactor         = mult;
            param.Method = AnalysisMethodType.SecondOrder;

            //Loads
            //lc.PrepareModification();
            rLoads.PrepareModification();
            try
            {
                lCase.SetAnalysisParameters(ref param);
            }
            finally
            {
                rLoads.FinishModification();
                //lc.FinishModification();
                lCase = null;
            }

            err = calc.Calculate(LoadingType.LoadCaseType, 1);
            if (err.Length == 0)
            {
                IResults       res   = calc.GetResultsInFeNodes(LoadingType.LoadCaseType, 1);
                MaximumResults max   = res.GetMaximum();
                Point3D        point = max.Displacement;
                double         value = Math.Sqrt(Math.Pow(point.X, 2) + Math.Pow(point.Y, 2) + Math.Pow(point.Z, 2));
                chart1.Series["deflection"].Points.AddXY(i, value);
            }
        }