示例#1
0
        // Helper function to determine if Robot has an active project open
        private bool IsRobotActive()
        {
            // Initialise connection to Robot if none exists
            if (!(iapp is RobotApplication))
            {
                iapp = new RobotApplication();
            }

            try
            {
                structure = iapp.Project.Structure;
                nodes     = structure.Nodes;
                bars      = structure.Bars;
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                ErrorDialog("Robot does not appear to be running", "ERROR: Robot not running");
                return(false);
            }

            if (iapp.Project.IsActive == 0)
            {
                ErrorDialog("No active Robot project was found", "ERROR: No active project");
                return(false);
            }

            return(true);
        }
示例#2
0
        public static void DumpMesh()
        {
            var RobApp = new RobotApplication();

            var t  = RobApp.Project.ViewMngr.CreateTable(IRobotTableType.I_TT_FINITE_ELEMENTS, IRobotTableDataType.I_TDT_FE);
            var tf = RobApp.Project.ViewMngr.GetTable(1);

            var FName = tf.Window.Caption;

            t.Select(IRobotSelectionType.I_ST_PANEL, "all");
            t.Select(IRobotSelectionType.I_ST_FINITE_ELEMENT, "all");
            tf.Get(2).Window.Activate();

            t          = tf.Get(2);
            tf.Current = 2;
            var tabname = tf.GetName(2);

            tabname = tabname.Replace(" ", "_");

            t.Printable.SaveToFile(@"C:\Users\GowthamanS\Desktop\Fe.txt", IRobotOutputFileFormat.I_OFF_TEXT);


            var nodes         = RobApp.Project.Structure.Nodes.GetAll();
            var stringBuilder = new StringBuilder();

            foreach (var i in Enumerable.Range(1, nodes.Count))
            {
                var node = nodes.Get(i) as RobotNode;
                stringBuilder.AppendLine($"{node.Number}, {node.X}, {node.Y}, {node.Z}");
            }

            File.WriteAllText(@"C:\Users\GowthamanS\Desktop\FeNodes.txt", stringBuilder.ToString());
        }
示例#3
0
        static void Main()
        {
            string filename = "V:\\1979\\Analysis\\Robot\\Curved glass\\190617 wireframe model\\wireframe_model vQ.rtd";

            var add_in    = new RobotOrientAddIn.RobotOrientAddIn();
            var robot_app = new RobotApplication
            {
                Visible     = 1,
                Interactive = 1
            };

            robot_app.Project.Open(filename);
            int add_in_id    = 0;
            var is_connected = add_in.Connect(robot_app, add_in_id, true);

            if (is_connected)
            {
                add_in.DoCommand(0);
            }
            else
            {
                Console.Write("Couldn't connect");
            }

            Console.Write("Press return key to continue...");
            Console.ReadLine();
        }
示例#4
0
        public bool Connect(RobotApplication robotApp, int addInId, bool firstTime)
        //Function wil be called up by the Robot application when the extension is connected to the program:
        //for the first time - upon user's request or during first activation of the program after installing the extension;
        //for the next time - while activating the Robot program again.
        //The extension should remember the access interface to the Robot application
        //(RobotApplication) so that the extension can use its functionality. The extension, while being connected,
        //is ascribed its identifier which should be remembered since it will be needed during subsequent communication
        //with the Robot program. While connecting the extension to the application for the first time it is possible
        //to perform additional initializing operations. If all is performed correctly,
        //then function should return a value different from zero (True).

        {
            try
            {
                Robapp  = robotApp;
                AddInId = addInId;
                Commandlist();

                if (firstTime == true)
                {
                    //Programdata();
                    //Reg.Register();
                    // Function saves information about the extension to the register.
                    //If registration is performed successfully,
                    //a value different from zero is returned (True).
                    //Registration failure may result from lack of settings concerning suppler name
                    //or product as well as identifier (Guid or Progld).
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
示例#5
0
        public void GetCases()
        {
            RobotApplication robapp = new RobotApplication();

            if (robapp == null)
            {
                return;
            }


            IRobotCaseCollection robotCaseCollection = robapp.Project.Structure.Cases.GetAll();

            for (int i = 0; i < robotCaseCollection.Count; i++)
            {
                try
                {
                    IRobotCase robotCase = robapp.Project.Structure.Cases.Get(i);
                    if (robotCase != null)
                    {
                        listBox1.Items.Add(robotCase.Name);
                    }
                }
                catch (Exception e)
                {
                }
            }

            if (listBox1.SelectedIndex == -1)
            {
                listBox1.SelectedIndex = 0;
            }


            robapp = null;
        }
示例#6
0
        private void button1_Click(object sender, EventArgs e)
        {
            RobotOM.RobotApplication robotapp = new RobotApplication();

            robotapp.Project.Structure.Nodes.Create(robotapp.Project.Structure.Nodes.FreeNumber, 0, 0, 0);

            robotapp.Project.ViewMngr.Refresh();
        }
示例#7
0
        public bool Connect(RobotApplication robotApp, int addInId, bool firstTime)
        {
            System.Diagnostics.Debugger.Launch();

            Robapp  = robotApp;
            AddInId = addInId;

            return(true);
        }
示例#8
0
 public bool Connect(RobotApplication robot_app, int add_in_id, bool first_time)
 {
     if (robot_app == null)
     {
         return(false);
     }
     this.robot_app = robot_app;
     return(true);
 }
        public void GetCases()
        {
            RobotApplication robapp = new RobotApplication();

            if (robapp == null)
            {
                return;
            }


            IRobotCaseCollection robotCaseCollection = robapp.Project.Structure.Cases.GetAll();
            List <string>        cases = new List <string>();
            int        ULSCase         = -1;
            IRobotCase robotCase       = robapp.Project.Structure.Cases.Get(1);

            for (int i = 0; i < robotCaseCollection.Count; i++)
            {
                try
                {
                    robapp.Project.Structure.Cases.Get(i);
                    robotCase = robapp.Project.Structure.Cases.Get(i);
                }
                catch (Exception)
                {
                    continue;
                    throw new Exception("Case Collection error");
                }
                finally
                {
                    robapp = null;
                }



                if (robotCase != null)
                {
                    cases.Add(robotCase.Name);
                    TextBlock.Text += robotCase.Name;
                    if (robotCase.Name == "ULS")
                    {
                        ULSCase = i - 1;
                    }
                }
            }

            listBox1.ItemsSource   = cases;
            listBox1.SelectedIndex = ULSCase;

            if (listBox1.SelectedIndex == -1)
            {
                listBox1.SelectedIndex = 0;
            }


            robapp = null;
        }
示例#10
0
        private static void AnalyseSingleBeam()
        {
            var robot = new RobotApplication();

            robot.Project.New(IRobotProjectType.I_PT_FRAME_2D);

            robot.Project.Structure.Nodes.Create(1, 0, 0, 0);
            robot.Project.Structure.Nodes.Create(2, 3, 0, 0);

            robot.Project.Structure.Bars.Create(1, 1, 2);

            var label = robot.Project.Structure.Labels.Create(IRobotLabelType.I_LT_SUPPORT, "Support");

            var supportData = label.Data as RobotNodeSupportData;

            supportData.UX = 1;
            supportData.UY = 1;
            supportData.UZ = 1;
            supportData.RX = 0;
            supportData.RY = 0;
            supportData.RZ = 0;

            robot.Project.Structure.Labels.Store(label);
            robot.Project.Structure.Nodes.Get(1).SetLabel(IRobotLabelType.I_LT_SUPPORT, "Support");
            robot.Project.Structure.Nodes.Get(2).SetLabel(IRobotLabelType.I_LT_SUPPORT, "Support");

            var barLabel    = robot.Project.Structure.Labels.Create(IRobotLabelType.I_LT_BAR_SECTION, "Beam50*50");
            var sectionData = barLabel.Data as RobotBarSectionData;

            sectionData.ShapeType = IRobotBarSectionShapeType.I_BSST_CONCR_BEAM_RECT;
            var concrete = sectionData.Concrete as RobotBarSectionConcreteData;

            concrete.SetValue(IRobotBarSectionConcreteDataValue.I_BSCDV_BEAM_B, 0.5);
            concrete.SetValue(IRobotBarSectionConcreteDataValue.I_BSCDV_BEAM_H, 0.5);

            sectionData.CalcNonstdGeometry();

            robot.Project.Structure.Labels.Store(barLabel);
            robot.Project.Structure.Bars.Get(1).SetLabel(IRobotLabelType.I_LT_BAR_SECTION, "Beam50*50");

            var lc = robot.Project.Structure.Cases.CreateSimple(1, "SW", IRobotCaseNature.I_CN_PERMANENT,
                                                                IRobotCaseAnalizeType.I_CAT_STATIC_LINEAR);

            lc.Records.New(IRobotLoadRecordType.I_LRT_DEAD);

            var rec = lc.Records.Get(1) as RobotLoadRecord;

            rec.SetValue((short)IRobotBarDeadRecordValues.I_BDRV_ENTIRE_STRUCTURE, 1);
            rec.SetValue((short)IRobotBarDeadRecordValues.I_BDRV_Z, -1);

            robot.Project.CalcEngine.Calculate();

            var result = robot.Project.Structure.Results.Bars.Forces.Value(1, 1, 0.5);

            Console.WriteLine($"{result.MX:F5} {result.MY:F5} {result.MZ:F5}");
        }
示例#11
0
        static void Main(string[] args)
        {
            var app = new RobotApplication();

            app.Project.Open(@"C:\Users\GowthamanS\Desktop\temp\Revit Files\SlabDesign\Structure.rtd");

            app.Project.CalcEngine.Calculate();

            var collection = app.Project.Structure.FiniteElems.GetAll();
            var loadCases  = app.Project.Structure.Cases.GetAll();

            for (var i = 0; i < collection.Count; i++)
            {
                var fe = collection.Get(i) as IRobotFiniteElement;
                if (fe != null)
                {
                    var number = fe.Number;
                    Console.WriteLine($"{number} - {fe.FeType}");
                    for (var j = 0; j < loadCases.Count; j++)
                    {
                        try
                        {
                            var loadCase   = loadCases.Get(j);// as IRobotCaseCombination;
                            var loadCaseId = loadCase.Number;

                            var param = new RobotFeResultParams();
                            param.Element = number;
                            param.Case    = loadCaseId;

                            param.Layer = IRobotFeLayerType.I_FLT_ARBITRARY;
                            param.LayerArbitraryValue = 0.25;

                            var princi  = app.Project.Structure.Results.FiniteElems.Principal(param);
                            var res_mom = princi.M1_2;
                            var res_for = princi.NAL;
                            var res_str = princi.S1;
                            var res_dis = princi.UGX;

                            Console.WriteLine($"{res_mom}_{res_for}_{res_str}_{res_dis}");
                        }
                        catch
                        {
                            Console.WriteLine("Error Loadcase");
                        }
                    }
                }
            }

            app.Project.Close();

            app = null;

            Console.ReadLine();
        }
示例#12
0
        public static void Bot()
        {
            RobotApplication rob = new RobotApplication();
            RobotStructure   str = rob.Project.Structure;

            str.Nodes.Create(1, 0, 0, 0);
            Console.WriteLine("Node Added.");

            str = null;
            rob = null;
            Console.ReadKey();
        }
示例#13
0
        void getMaterialNameListRSA(RobotApplication appRSA)
        {
            RobotLabelServer labelsRSA = appRSA.Project.Structure.Labels;
            //RobotLabel labelRSA;
            RobotNamesArray namArrRSA = labelsRSA.GetAvailableNames(IRobotLabelType.I_LT_MATERIAL);

            string[] tmp = new string[namArrRSA.Count];
            for (int i = 0; i < namArrRSA.Count; i++)
            {
                tmp[i] = namArrRSA.Get(i + 1);
            }
            MaterialsRSA = tmp;
        }
示例#14
0
        void getBarSectionNamesRSA(RobotApplication appRSA)
        {
            RobotLabelServer labelsRSA = appRSA.Project.Structure.Labels;
            //RobotLabel labelRSA;
            RobotNamesArray namArrRSA = labelsRSA.GetAvailableNames(IRobotLabelType.I_LT_BAR_SECTION);

            string[] tmp = new string[namArrRSA.Count];
            for (int i = 0; i < namArrRSA.Count; i++)
            {
                tmp[i] = namArrRSA.Get(i + 1);
            }
            NamesSectBar = tmp;
        }
示例#15
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         robapp = new RobotApplication();
         CopyData();
     }
     catch (Exception E)
     {
     }
     finally
     {
         robapp = null;
         CloseExcel();
     }
 }
示例#16
0
        public void test()
        {
            RobotApplication appRSA = new RobotApplication();

            getMaterialNameListRSA(appRSA);
            getBarSectionNamesRSA(appRSA);
            RobotStructure       structureRSA = appRSA.Project.Structure;
            RobotBarServer       barsRSA      = structureRSA.Bars;
            RobotNodeServer      nodesRSA     = structureRSA.Nodes;
            RobotObjObjectServer objRSA       = structureRSA.Objects;

            RobotLabelServer labelsRSA = appRSA.Project.Structure.Labels;

            //Определение выборок выделенных в модели объектов
            RobotSelection barSel   = structureRSA.Selections.Get(IRobotObjectType.I_OT_BAR);
            RobotSelection plateSel = structureRSA.Selections.Get(IRobotObjectType.I_OT_PANEL);
            RobotSelection holesSel = structureRSA.Selections.Get(IRobotObjectType.I_OT_GEOMETRY);

            RobotBarCollection       barsMany   = (RobotBarCollection)barsRSA.GetMany(barSel);
            RobotObjObjectCollection platesMany = (RobotObjObjectCollection)objRSA.GetMany(plateSel);
            IRobotBar       barRSA = barsMany.Get(3);
            IRobotObjObject plate  = platesMany.Get(1);

            IRobotLabel labelPlate = plate.GetLabel(IRobotLabelType.I_LT_PANEL_THICKNESS);
            RobotGeoPoint3DCollection defPoints = (RobotGeoPoint3DCollection)plate.Main.DefPoints;
            RobotGeoPoint3D           pt1       = defPoints.Get(1);
            RobotGeoPoint3D           pt2       = defPoints.Get(2);
            RobotGeoPoint3D           pt3       = defPoints.Get(defPoints.Count);
            //IRobotGeoContour geoContour=(IRobotGeoContour)plate.Main.Geometry;
            //IRobotGeoObject geoObj=plate.Main.Geometry;

            IRobotLabel                 labelBar = barRSA.GetLabel(IRobotLabelType.I_LT_BAR_SECTION);
            RobotBarSectionData         data     = labelBar.Data;
            RobotBarSectionConcreteData cData    = data.Concrete;
            double b    = cData.GetValue(IRobotBarSectionConcreteDataValue.I_BSCDV_COL_B);
            double h    = cData.GetValue(IRobotBarSectionConcreteDataValue.I_BSCDV_COL_H);
            double l1   = cData.GetValue(IRobotBarSectionConcreteDataValue.I_BSCDV_COL_L1);
            double l2   = cData.GetValue(IRobotBarSectionConcreteDataValue.I_BSCDV_COL_L2);
            double h1   = cData.GetValue(IRobotBarSectionConcreteDataValue.I_BSCDV_COL_H1);
            double h2   = cData.GetValue(IRobotBarSectionConcreteDataValue.I_BSCDV_COL_H2);
            double de   = cData.GetValue(IRobotBarSectionConcreteDataValue.I_BSCDV_COL_DE);
            double alfa = barRSA.Gamma;
        }
示例#17
0
        private void button1_Click(object sender, EventArgs e)
        {
            Excel.Application xlApp        = new Excel.Application();
            Excel.Workbook    xlWorkbook   = xlApp.Workbooks.Open(@"EXCELPATH...\excelFile.xlsx", 0, false);
            Excel.Sheets      xlSheets     = xlWorkbook.Worksheets;
            string            currentSheet = "Sheet1";

            Excel.Worksheet   xlWorksheet = (Excel.Worksheet)xlSheets.get_Item(currentSheet);
            IRobotApplication robotApp    = new RobotApplication();
            IRobotLabelServer lab_serv    = robotApp.Project.Structure.Labels;

            progressBar1.Value   = 0;
            progressBar1.Maximum = 151;
            progressBar1.Minimum = 0;
            progressBar1.Step    = 1;


            for (int i = 1; i < 152; i++)
            {
                string secName = xlWorksheet.Cells[i + 1, 1].Value.ToString();
                double secAx   = double.Parse(xlWorksheet.Cells[i + 1, 2].Value.ToString());
                double secIx   = double.Parse(xlWorksheet.Cells[i + 1, 3].Value.ToString());
                double secIy   = double.Parse(xlWorksheet.Cells[i + 1, 4].Value.ToString());
                double secIz   = double.Parse(xlWorksheet.Cells[i + 1, 5].Value.ToString());
                double secVy   = double.Parse(xlWorksheet.Cells[i + 1, 6].Value.ToString());
                double secVpy  = double.Parse(xlWorksheet.Cells[i + 1, 7].Value.ToString());
                double secVz   = double.Parse(xlWorksheet.Cells[i + 1, 8].Value.ToString());
                double secVpz  = double.Parse(xlWorksheet.Cells[i + 1, 9].Value.ToString());


                IRobotLabel          sec  = lab_serv.Create(IRobotLabelType.I_LT_BAR_SECTION, secName);
                IRobotBarSectionData data = sec.Data;
                data.Type      = IRobotBarSectionType.I_BST_STANDARD;
                data.ShapeType = IRobotBarSectionShapeType.I_BSST_UNKNOWN;

                data.SetValue(IRobotBarSectionDataValue.I_BSDV_AX, secAx);
                data.SetValue(IRobotBarSectionDataValue.I_BSDV_IX, secIx);
                data.SetValue(IRobotBarSectionDataValue.I_BSDV_IY, secIy);
                data.SetValue(IRobotBarSectionDataValue.I_BSDV_IZ, secIz);
                data.SetValue(IRobotBarSectionDataValue.I_BSDV_VY, secVy);
                data.SetValue(IRobotBarSectionDataValue.I_BSDV_VPY, secVpy);
                data.SetValue(IRobotBarSectionDataValue.I_BSDV_VZ, secVz);
                data.SetValue(IRobotBarSectionDataValue.I_BSDV_VPZ, secVpz);

                lab_serv.Store(sec);

                IRobotBar bar = (IRobotBar)robotApp.Project.Structure.Bars.Get(i);

                bar.SetLabel(IRobotLabelType.I_LT_BAR_SECTION, secName);

                progressBar1.PerformStep();
            }

            Marshal.FinalReleaseComObject(xlWorksheet);
            Marshal.FinalReleaseComObject(xlSheets);
            xlWorkbook.Close(false);
            Marshal.FinalReleaseComObject(xlWorkbook);
            xlApp.Quit();
            Marshal.FinalReleaseComObject(xlApp);

            MessageBox.Show("All the profiles have been applied!", "Work done !", MessageBoxButtons.OK);
        }
示例#18
0
        private static void FromTutorial()
        {
            var robApp = new RobotApplication();

            if (robApp.Visible == 0)
            {
                robApp.Interactive = 1;
                robApp.Visible     = 1;
            }
            robApp.Project.New(IRobotProjectType.I_PT_SHELL);
            var projectPrefs = robApp.Project.Preferences;

            projectPrefs.SetActiveCode(IRobotCodeType.I_CT_RC_THEORETICAL_REINF, "BAEL 91");
            var meshParams = projectPrefs.MeshParams;

            meshParams.SurfaceParams.Method.Method          = IRobotMeshMethodType.I_MMT_DELAUNAY;
            meshParams.SurfaceParams.Generation.Type        = IRobotMeshGenerationType.I_MGT_ELEMENT_SIZE;
            meshParams.SurfaceParams.Generation.ElementSize = 0.5;
            meshParams.SurfaceParams.Delaunay.Type          = IRobotMeshDelaunayType.I_MDT_DELAUNAY;

            IRobotStructure str = robApp.Project.Structure;

            str.Nodes.Create(1, 0, 0, 0);
            str.Nodes.Create(2, 3, 0, 0);
            str.Nodes.Create(3, 3, 3, 0);
            str.Nodes.Create(4, 0, 3, 0);
            str.Nodes.Create(5, 0, 0, 4);

            str.Nodes.Create(6, 3, 0, 4);
            str.Nodes.Create(7, 3, 3, 4);
            str.Nodes.Create(8, 0, 3, 4);

            str.Bars.Create(1, 1, 5);
            str.Bars.Create(2, 2, 6);
            str.Bars.Create(3, 3, 7);
            str.Bars.Create(4, 4, 8);
            str.Bars.Create(5, 5, 6);
            str.Bars.Create(6, 7, 8);

            var labels            = str.Labels;
            var columnSectionName = "Rect. Column 30*30";

            var label   = labels.Create(IRobotLabelType.I_LT_BAR_SECTION, columnSectionName);
            var section = (RobotBarSectionData)label.Data;

            section.ShapeType = IRobotBarSectionShapeType.I_BSST_CONCR_COL_R;

            var concrete = (RobotBarSectionConcreteData)section.Concrete;

            concrete.SetValue(IRobotBarSectionConcreteDataValue.I_BSCDV_COL_B, 0.3);
            concrete.SetValue(IRobotBarSectionConcreteDataValue.I_BSCDV_COL_H, 0.3);
            section.CalcNonstdGeometry();
            labels.Store(label);
            var selectionBars = str.Selections.Get(IRobotObjectType.I_OT_BAR);

            selectionBars.FromText("1 2 3 4");
            str.Bars.SetLabel(selectionBars, IRobotLabelType.I_LT_BAR_SECTION, columnSectionName);
            var steelSections = projectPrefs.SectionsActive;

            if (steelSections.Add("RCAT") == 1)
            {
                Console.WriteLine("Steel section base RCAT not found...");
            }
            selectionBars.FromText("5 6");
            label = labels.Create(IRobotLabelType.I_LT_BAR_SECTION, "HEA 340");
            str.Labels.Store(label);
            str.Bars.SetLabel(selectionBars, IRobotLabelType.I_LT_BAR_SECTION, "HEA 340");
            var materialName = "Concrete 30";

            label = labels.Create(IRobotLabelType.I_LT_MATERIAL, materialName);
            var material = (RobotMaterialData)label.Data;

            material.Type = IRobotMaterialType.I_MT_CONCRETE;
            material.E    = 30000000000;   // Young
            material.NU   = 1 / (double)6; // Poisson

            material.RO       = 25000;     // Unit weight
            material.Kirchoff = material.E / (2 * (1 + material.NU));
            str.Labels.Store(label);
            var points = (RobotPointsArray)robApp.CmpntFactory.Create(IRobotComponentType.I_CT_POINTS_ARRAY);

            points.SetSize(5);
            points.Set(1, 0, 0, 4);
            points.Set(2, 3, 0, 4);
            points.Set(3, 3, 3, 4);
            points.Set(4, 0, 3, 4);
            points.Set(5, 0, 0, 4);
            var slabSectionName = "Slab 30";

            label = labels.Create(IRobotLabelType.I_LT_PANEL_THICKNESS, slabSectionName);
            var thickness = (RobotThicknessData)label.Data;

            thickness.MaterialName  = materialName;
            thickness.ThicknessType = IRobotThicknessType.I_TT_HOMOGENEOUS;
            var thicknessData = (RobotThicknessHomoData)thickness.Data;

            thicknessData.ThickConst = 0.3;
            labels.Store(label);
            var objNumber = str.Objects.FreeNumber;

            str.Objects.CreateContour(objNumber, points);
            var slab = (RobotObjObject)str.Objects.Get(objNumber);

            slab.Main.Attribs.Meshed = 1;
            slab.SetLabel(IRobotLabelType.I_LT_PANEL_THICKNESS, slabSectionName);
            slab.Initialize();
            points.Set(1, 1.1, 1.1, 4);
            points.Set(2, 2.5, 1.1, 4);
            points.Set(3, 2.5, 2.5, 4);
            points.Set(4, 1.1, 2.5, 4);
            points.Set(5, 1.1, 1.1, 4);
            var holeNumber = str.Objects.FreeNumber;

            str.Objects.CreateContour(holeNumber, points);
            var hole = (RobotObjObject)str.Objects.Get(holeNumber);

            hole.Main.Attribs.Meshed = 0;
            hole.Initialize();
            var footName = "Foot";

            label = labels.Create(IRobotLabelType.I_LT_SUPPORT, footName);
            var footData = (RobotNodeSupportData)label.Data;

            footData.UX = 1;
            footData.UY = 1;
            footData.UZ = 1;
            footData.KZ = 80000000;
            footData.RX = 1;

            footData.RY = 1;
            footData.RZ = 1;
            labels.Store(label);
            var selectionNodes = str.Selections.Get(IRobotObjectType.I_OT_NODE);

            selectionNodes.FromText("1 2 3 4");
            str.Nodes.SetLabel(selectionNodes, IRobotLabelType.I_LT_SUPPORT, footName);
            //self weight on entire structure
            var caseSw = str.Cases.CreateSimple(1, "SW", IRobotCaseNature.I_CN_PERMANENT, IRobotCaseAnalizeType.I_CAT_STATIC_LINEAR);

            caseSw.Records.New(IRobotLoadRecordType.I_LRT_DEAD);
            var loadRecord = (RobotLoadRecord)caseSw.Records.Get(1);

            loadRecord.SetValue(System.Convert.ToInt16(IRobotDeadRecordValues.I_DRV_Z), -1);
            loadRecord.SetValue(System.Convert.ToInt16(IRobotDeadRecordValues.I_DRV_ENTIRE_STRUCTURE), 0);
            //contour live load on the slab
            var caseLive = str.Cases.CreateSimple(2, "Live", IRobotCaseNature.I_CN_EXPLOATATION, IRobotCaseAnalizeType.I_CAT_STATIC_LINEAR);
            var uniform  = caseLive.Records.New(IRobotLoadRecordType.I_LRT_UNIFORM);

            loadRecord = (RobotLoadRecord)caseLive.Records.Get(uniform);
            loadRecord.SetValue(System.Convert.ToInt16(IRobotUniformRecordValues.I_URV_PX), 0);
            loadRecord.SetValue(System.Convert.ToInt16(IRobotUniformRecordValues.I_URV_PY), 0);
            loadRecord.SetValue(System.Convert.ToInt16(IRobotUniformRecordValues.I_URV_PZ), -10000);
            //apply created load to the slab
            loadRecord.Objects.FromText(System.Convert.ToString(objNumber));
            //linear wind load on the beam
            var caseWind = str.Cases.CreateSimple(3, "Wind", IRobotCaseNature.I_CN_WIND, IRobotCaseAnalizeType.I_CAT_STATIC_LINEAR);

            uniform    = caseWind.Records.New(IRobotLoadRecordType.I_LRT_BAR_UNIFORM);
            loadRecord = (RobotLoadRecord)caseWind.Records.Get(uniform);
            loadRecord.SetValue(System.Convert.ToInt16(IRobotUniformRecordValues.I_URV_PX), 0);
            loadRecord.SetValue(System.Convert.ToInt16(IRobotUniformRecordValues.I_URV_PY), 1000);

            loadRecord.SetValue(System.Convert.ToInt16(IRobotUniformRecordValues.I_URV_PZ), 0);
            //apply created load to the beam
            loadRecord.Objects.FromText("5");
            var calcEngine = robApp.Project.CalcEngine;

            calcEngine.GenerationParams.GenerateNodes_BarsAndFiniteElems = true;
            calcEngine.UseStatusWindow = true;

            if (calcEngine.Calculate() == 1)
            {
                Console.WriteLine("Calculation Failed!");
            }
            else
            {
                Console.WriteLine("Done!");
            }

            calcEngine = null;

            //CalcReinforcement(robApp, objNumber, labels, slab, str);
        }
示例#19
0
        public void CopyData()
        {
            button1.Text = "Loading...";
            //this.WindowState = FormWindowState.Minimized;


            //-------------------------------------
            //Load Cases
            IRobotCaseCollection robotCaseCollection = robapp.Project.Structure.Cases.GetAll();
            int loadCase = 0;

            int FindCase(string casename)
            {
                int        number    = 1;
                IRobotCase robotCase = robapp.Project.Structure.Cases.Get(1);

                for (int i = 0; i < robotCaseCollection.Count; i++)
                {
                    robotCase = robapp.Project.Structure.Cases.Get(i);
                    if (robotCase != null)
                    {
                        if (robotCase.Name == casename)
                        {
                            number = i;
                            break;
                        }
                    }
                }
                loadCase = number;
                return(number);
            }

            //-------------------------------------
            //Get Number of Bars Selected
            RobotSelection barSel = robapp.Project.Structure.Selections.Get(IRobotObjectType.I_OT_BAR);
            //Get All Load Cases
            RobotSelection casSel = robapp.Project.Structure.Selections.Get(IRobotObjectType.I_OT_CASE);

            //Get Bar and Node Data
            IRobotBarServer  robotBarServer = robapp.Project.Structure.Bars;
            IRobotNodeServer inds           = robapp.Project.Structure.Nodes;

            //Get a List of the bars and Setup bar information Struct
            int[]            barSelArray = new int[barSel.Count];
            BeamDataStruct[] beamData    = new BeamDataStruct[barSelArray.Length];
            for (int i = 1; i < barSel.Count + 1; i++)
            {
                //Setup bar no. array
                barSelArray[i - 1] = barSel.Get(i);

                //Get node information from bar data
                IRobotBar  bar         = (IRobotBar)robotBarServer.Get(barSelArray[i - 1]);
                int        startNodeNo = bar.StartNode;
                int        endNodeNo   = bar.EndNode;
                IRobotNode startNode   = (IRobotNode)inds.Get(startNodeNo);
                IRobotNode endNode     = (IRobotNode)inds.Get(endNodeNo);

                //If a Beam, Skip
                if (startNode.Z == endNode.Z)
                {
                    continue;
                }

                //Which is highest node
                IRobotNode node = (startNode.Z > endNode.Z) ? startNode : endNode;

                //Populate beam data from node and bar data.
                beamData[i - 1].barNo = barSelArray[i - 1];

                IRobotBarSectionData sectData = bar.GetLabel(IRobotLabelType.I_LT_BAR_SECTION).Data;
                double depth  = sectData.GetValue(IRobotBarSectionDataValue.I_BSDV_BF);
                double breath = sectData.GetValue(IRobotBarSectionDataValue.I_BSDV_D);
                if (depth < breath)
                {
                    double holder = breath;
                    breath = depth;
                    depth  = holder;
                }
                depth  = depth * 1000;
                breath = breath * 1000;
                beamData[i - 1].section = $"C1 {depth} x {breath}";
                beamData[i - 1].x       = node.X;
                beamData[i - 1].y       = node.Y;
                beamData[i - 1].z       = node.Z;
                beamData[i - 1].height  = bar.Length;
                IRobotMaterialData concrete  = bar.GetLabel(IRobotLabelType.I_LT_MATERIAL).Data;
                Double             concreteS = concrete.RE / 1000000;
                beamData[i - 1].concreteStrength = concreteS.ToString();
            }

            textBox2.AppendText("\r\nSorting\r\n");
            beamData = beamData.OrderBy(x => x.z).ToArray();
            beamData = beamData.OrderBy(x => x.y).ToArray();
            beamData = beamData.OrderBy(x => x.x).ToArray();

            int group      = 1;
            int posInGroup = 0;

            for (int i = 0; i < beamData.Length; i++)
            {
                posInGroup = 0;


                for (int j = 0; j < beamData.Length; j++)
                {
                    if (beamData[i].x - beamData[j].x < 0.0001 && beamData[i].y - beamData[j].y < 0.0001 && beamData[i].barNo != beamData[j].barNo)
                    {
                        if (beamData[j].group != 0)
                        {
                            beamData[i].group = beamData[j].group;
                            for (int k = 0; k < beamData.Length; k++)
                            {
                                if (beamData[i].group == beamData[k].group && beamData[i].barNo != beamData[k].barNo)
                                {
                                    posInGroup++;
                                }
                            }
                            beamData[i].posInGroup = posInGroup;
                        }
                        else
                        {
                            beamData[i].group = group;
                            group++;
                        }
                        break;
                    }
                }
            }

            void CalculateResults()
            {
                textBox2.AppendText($"\r\nStarting calculation: {DateTime.Now.ToString("h:mm:ss tt")}");
                RobotExtremeParams robotExtremeParams = robapp.CmpntFactory.Create(IRobotComponentType.I_CT_EXTREME_PARAMS);

                robapp.Project.Structure.Selections.Get(IRobotObjectType.I_OT_CASE).FromText(FindCase(listBox1.SelectedItem.ToString()).ToString());
                robotExtremeParams.Selection.Set(IRobotObjectType.I_OT_CASE, casSel);
                IRobotBarForceServer robotBarResultServer = robapp.Project.Structure.Results.Bars.Forces;
                int    total           = beamData.Length;
                bool   firstLoop       = true;
                string columnsSelected = "";

                for (int i = 0; i < beamData.Length; i++)
                {
                    DateTime startTime = DateTime.Now;
                    textBox2.AppendText($"\r\nStart Calculation {i + 1} / {total} before bar selection: {DateTime.Now.ToString("h:mm:ss tt")}");
                    robapp.Project.Structure.Selections.Get(IRobotObjectType.I_OT_BAR).FromText(beamData[i].barNo.ToString());
                    robotExtremeParams.Selection.Set(IRobotObjectType.I_OT_BAR, barSel);


                    //MZ
                    robotExtremeParams.ValueType = IRobotExtremeValueType.I_EVT_FORCE_BAR_MZ;

                    if (Math.Abs(robapp.Project.Structure.Results.Extremes.MaxValue(robotExtremeParams).Value) > Math.Abs(robapp.Project.Structure.Results.Extremes.MinValue(robotExtremeParams).Value))
                    {
                        beamData[i].mZForceServer    = robotBarResultServer.ValueEx(beamData[i].barNo, loadCase, robapp.Project.Structure.Results.Extremes.MaxValue(robotExtremeParams).CaseCmpnt, 1);
                        beamData[i].mZForceServerbtm = robotBarResultServer.ValueEx(beamData[i].barNo, loadCase, robapp.Project.Structure.Results.Extremes.MaxValue(robotExtremeParams).CaseCmpnt, 0);
                    }
                    else
                    {
                        beamData[i].mZForceServer    = robotBarResultServer.ValueEx(beamData[i].barNo, loadCase, robapp.Project.Structure.Results.Extremes.MinValue(robotExtremeParams).CaseCmpnt, 1);
                        beamData[i].mZForceServerbtm = robotBarResultServer.ValueEx(beamData[i].barNo, loadCase, robapp.Project.Structure.Results.Extremes.MinValue(robotExtremeParams).CaseCmpnt, 0);
                    }

                    beamData[i].mzValue = Math.Abs(beamData[i].mZForceServer.MZ) > Math.Abs(beamData[i].mZForceServerbtm.MZ) ? beamData[i].mZForceServer.FX : beamData[i].mZForceServerbtm.FX;



                    //MY
                    robotExtremeParams.ValueType = IRobotExtremeValueType.I_EVT_FORCE_BAR_MY;

                    if (Math.Abs(robapp.Project.Structure.Results.Extremes.MaxValue(robotExtremeParams).Value) > Math.Abs(robapp.Project.Structure.Results.Extremes.MinValue(robotExtremeParams).Value))
                    {
                        beamData[i].mYForceServer    = robotBarResultServer.ValueEx(beamData[i].barNo, loadCase, robapp.Project.Structure.Results.Extremes.MaxValue(robotExtremeParams).CaseCmpnt, 1);
                        beamData[i].mYForceServerbtm = robotBarResultServer.ValueEx(beamData[i].barNo, loadCase, robapp.Project.Structure.Results.Extremes.MaxValue(robotExtremeParams).CaseCmpnt, 0);
                    }
                    else
                    {
                        beamData[i].mYForceServer    = robotBarResultServer.ValueEx(beamData[i].barNo, loadCase, robapp.Project.Structure.Results.Extremes.MinValue(robotExtremeParams).CaseCmpnt, 1);
                        beamData[i].mYForceServerbtm = robotBarResultServer.ValueEx(beamData[i].barNo, loadCase, robapp.Project.Structure.Results.Extremes.MinValue(robotExtremeParams).CaseCmpnt, 0);
                    }

                    beamData[i].myValue = Math.Abs(beamData[i].mYForceServer.MY) > Math.Abs(beamData[i].mYForceServerbtm.MY) ? beamData[i].mYForceServer.FX : beamData[i].mYForceServerbtm.FX;



                    //FX
                    robotExtremeParams.ValueType = IRobotExtremeValueType.I_EVT_FORCE_BAR_FX;

                    if (Math.Abs(robapp.Project.Structure.Results.Extremes.MaxValue(robotExtremeParams).Value) > Math.Abs(robapp.Project.Structure.Results.Extremes.MinValue(robotExtremeParams).Value))
                    {
                        beamData[i].fXForceServer    = robotBarResultServer.ValueEx(beamData[i].barNo, loadCase, robapp.Project.Structure.Results.Extremes.MaxValue(robotExtremeParams).CaseCmpnt, 1);
                        beamData[i].fXForceServerbtm = robotBarResultServer.ValueEx(beamData[i].barNo, loadCase, robapp.Project.Structure.Results.Extremes.MaxValue(robotExtremeParams).CaseCmpnt, 0);
                    }
                    else
                    {
                        beamData[i].fXForceServer    = robotBarResultServer.ValueEx(beamData[i].barNo, loadCase, robapp.Project.Structure.Results.Extremes.MinValue(robotExtremeParams).CaseCmpnt, 1);
                        beamData[i].fXForceServerbtm = robotBarResultServer.ValueEx(beamData[i].barNo, loadCase, robapp.Project.Structure.Results.Extremes.MinValue(robotExtremeParams).CaseCmpnt, 0);
                    }

                    beamData[i].fxValue = Math.Abs(beamData[i].fXForceServer.FX) > Math.Abs(beamData[i].fXForceServerbtm.FX) ? beamData[i].fXForceServer.FX : beamData[i].fXForceServerbtm.FX;


                    double totalTime = (DateTime.Now - startTime).TotalSeconds;
                    textBox2.AppendText($"\r\nEnd Calculation {i + 1} / {total} {DateTime.Now.ToString("h:mm:ss tt")} \r\nTime taken: {totalTime}");

                    if (firstLoop)
                    {
                        textBox2.AppendText($"\r\nEstimated finish time: {DateTime.Now.AddSeconds(total * totalTime).ToString("h:mm:ss tt")}");
                        firstLoop = false;
                    }

                    columnsSelected += $"{beamData[i].barNo.ToString()} ";
                }

                textBox2.AppendText($"\r\ncolumns selected {columnsSelected}");
                robapp.Project.Structure.Selections.Get(IRobotObjectType.I_OT_BAR).FromText(columnsSelected);
            }

            int maxCol = 1;

            void WriteResults()
            {
                int column       = 1;
                int currentGroup = 0;

                for (int i = 0; i < beamData.Length; i++)
                {
                    if (beamData[i].group == currentGroup)
                    {
                        column = beamData[i].posInGroup;
                        if (column >= maxCol)
                        {
                            maxCol = column;
                        }
                    }
                    else
                    {
                        currentGroup++;
                        column = 0;
                    }

                    int row       = currentGroup + 2;
                    int columnPos = beamData[i].posInGroup + 1;
                    WriteCell(row, 0, columnPos.ToString());

                    WriteCell(row, 1 + 22 * column, beamData[i].section.ToString());
                    WriteCell(row, 2 + 22 * column, beamData[i].barNo.ToString());
                    WriteCell(row, 3 + 22 * column, beamData[i].concreteStrength.ToString());
                    WriteCell(row, 4 + 22 * column, beamData[i].group.ToString());
                    WriteCell(row, 5 + 22 * column, beamData[i].posInGroup.ToString());
                    WriteCell(row, 6 + 22 * column, beamData[i].height.ToString());

                    WriteCell(row, 7 + 22 * column, (beamData[i].fxValue / 1000).ToString());
                    WriteCell(row, 8 + 22 * column, (beamData[i].fXForceServer.MY / 1000).ToString());
                    WriteCell(row, 9 + 22 * column, (beamData[i].fXForceServer.MZ / 1000).ToString());
                    WriteCell(row, 10 + 22 * column, (beamData[i].fXForceServerbtm.MY / 1000).ToString());
                    WriteCell(row, 11 + 22 * column, (beamData[i].fXForceServerbtm.MZ / 1000).ToString());


                    WriteCell(row, 12 + 22 * column, (beamData[i].mzValue / 1000).ToString());
                    WriteCell(row, 13 + 22 * column, (beamData[i].mZForceServer.MY / 1000).ToString());
                    WriteCell(row, 14 + 22 * column, (beamData[i].mZForceServer.MZ / 1000).ToString());
                    WriteCell(row, 15 + 22 * column, (beamData[i].mZForceServerbtm.MY / 1000).ToString());
                    WriteCell(row, 16 + 22 * column, (beamData[i].mZForceServerbtm.MZ / 1000).ToString());


                    WriteCell(row, 17 + 22 * column, (beamData[i].myValue / 1000).ToString());
                    WriteCell(row, 18 + 22 * column, (beamData[i].mYForceServer.MY / 1000).ToString());
                    WriteCell(row, 19 + 22 * column, (beamData[i].mYForceServer.MZ / 1000).ToString());
                    WriteCell(row, 20 + 22 * column, (beamData[i].mYForceServerbtm.MY / 1000).ToString());
                    WriteCell(row, 21 + 22 * column, (beamData[i].mYForceServerbtm.MZ / 1000).ToString());
                }

                WriteCell(0, 0, currentGroup.ToString());
            }

            void PopulateHeaders()
            {
                for (int i = 0; i <= maxCol; i++)
                {
                    //Headers
                    WriteCell(1, 1 + 22 * i, "Cross Section");
                    WriteCell(1, 2 + 22 * i, "Bar No.");
                    WriteCell(1, 3 + 22 * i, "Concrete Strength");
                    WriteCell(1, 4 + 22 * i, "Group");
                    WriteCell(1, 5 + 22 * i, "Pos In Group");
                    WriteCell(1, 6 + 22 * i, "Length");

                    //FZ Max
                    WriteCell(1, 7 + 22 * i, "Fx (Max) [kN]");
                    WriteCell(1, 8 + 22 * i, "My (Top) [kNm]");
                    WriteCell(1, 9 + 22 * i, "Mz (Top) [kNm]");
                    WriteCell(1, 10 + 22 * i, "My (Btm) [kNm]");
                    WriteCell(1, 11 + 22 * i, "Mz (Btm) [kNm]");

                    //MX Max
                    WriteCell(1, 12 + 22 * i, "Fx (Max) [kN]");
                    WriteCell(1, 13 + 22 * i, "My (Top) [kNm]");
                    WriteCell(1, 14 + 22 * i, "Mz (Top) [kNm]");
                    WriteCell(1, 15 + 22 * i, "My (Btm) [kNm]");
                    WriteCell(1, 16 + 22 * i, "Mz (Btm) [kNm]");

                    //MY Max
                    WriteCell(1, 17 + 22 * i, "Fx (Max) [kN])");
                    WriteCell(1, 18 + 22 * i, "My (Top) [kNm]");
                    WriteCell(1, 19 + 22 * i, "Mz (Top) [kNm]");
                    WriteCell(1, 20 + 22 * i, "My (Btm) [kNm]");
                    WriteCell(1, 21 + 22 * i, "Mz (Btm) [kNm]");

                    //Headers
                    WriteCell(0, 9 + 22 * i, "Fx (Max)");
                    WriteCell(0, 14 + 22 * i, "Mz (Max)");
                    WriteCell(0, 19 + 22 * i, "My (Max)");
                }
            }

            WriteData();
            CalculateResults();
            WriteResults();
            PopulateHeaders();
            SaveExcel();
            CloseExcel();
            button1.Text = "Start";
            textBox2.AppendText("\r\nDone, view your documents for the file named 'Results for bars ~date~', you may close this window or select more columns and press 'Start'.");
            robapp           = null;
            this.WindowState = FormWindowState.Normal;
        }
示例#20
0
        private static void CalcReinforcement(RobotApplication robApp, int objNumber, RobotLabelServer labels, RobotObjObject slab, IRobotStructure str)
        {
            IRobotLabel label;
            var         concrCalcEngine = robApp.Project.ConcrReinfEngine;
            var         concrSlabRequiredReinfEngine = concrCalcEngine.SlabRequiredReinf;
            var         slabRnfParams = concrSlabRequiredReinfEngine.Params;

            slabRnfParams.Method = IRobotReinforceCalcMethods.I_RCM_WOOD_ARMER;
            slabRnfParams.GloballyAvgDesginForces = false;
            slabRnfParams.ForcesReduction         = false;
            slabRnfParams.DisplayErrors           = false;
            slabRnfParams.CasesULS.FromText("1 2 3 4 5 6 7 8");
            var slabs = slabRnfParams.Panels;

            slabs.FromText(System.Convert.ToString(objNumber));
            var slabReinforcementName = "Slab X";

            label = labels.Create(IRobotLabelType.I_LT_PANEL_REINFORCEMENT, slabReinforcementName);
            labels.Store(label);
            slab.SetLabel(IRobotLabelType.I_LT_PANEL_REINFORCEMENT, slabReinforcementName);
            slab.Update();

            Console.WriteLine(!concrSlabRequiredReinfEngine.Calculate() ? "Calculation Failed!" : "Done!");
            //getting results My and Yz for beam (bar 5) with live load (case 2)
            var txt = "Bar 5, Live at 0.5 length:" + "\n\r" +
                      " My = " + str.Results.Bars.Forces.Value(5, 2, 0.5).MY / 1000 + " [kN*m]" + "\n\r" +
                      " Qz = " + -str.Results.Bars.Deflections.Value(5, 2, 0.5).UZ * 1000 + " [mm]" + "\n\r" +
                      " Fz1 = " + str.Results.Bars.Forces.Value(5, 2, 0).FZ / 1000 + " [kN]" + "\n\r" +
                      " Fz2 = " + str.Results.Bars.Forces.Value(5, 2, 1).FZ / 1000 + " [kN]" + "\n\r";

            //getting results Fx and Fy for column (bar 4) with wind load (case 3)
            txt += "Bar 4, Wind:" + "\n\r" +
                   " Fx = " + str.Results.Bars.Forces.Value(4, 3, 1).FX / 1000 + " [kN]" + "\n\r" +
                   " Fy = " + str.Results.Bars.Forces.Value(4, 3, 1).FY / 1000 + " [kN]" + "\n\r";
            //getting results Fx, Fy, Fz, Mx, My, Mz for foot (node 1) with self-weight (case 1)
            txt += "Node 1, Self-Weight:" + "\n\r" +
                   " Fx = " + str.Results.Nodes.Reactions.Value(1, 1).FX / 1000 + " [kN]" + "\n\r" +
                   " Fy = " + str.Results.Nodes.Reactions.Value(1, 1).FY / 1000 + " [kN]" + "\n\r" +
                   " Fz = " + str.Results.Nodes.Reactions.Value(1, 1).FZ / 1000 + " [kN]" + "\n\r" +
                   " Mx = " + str.Results.Nodes.Reactions.Value(1, 1).MX / 1000 + " [kN]" + "\n\r" +
                   " My = " + str.Results.Nodes.Reactions.Value(1, 1).MY / 1000 + " [kN]" + "\n\r" +
                   " Mz = " + str.Results.Nodes.Reactions.Value(1, 1).MZ / 1000 + " [kN]" + "\n\r";
            //getting results Ax+, Ax-, Ay+, Ay- for slab
            var selectionFe = str.Selections.Get(IRobotObjectType.I_OT_FINITE_ELEMENT);

            selectionFe.FromText(slab.FiniteElems);
            var    objFEs = (RobotLabelCollection)str.FiniteElems.GetMany(selectionFe);
            double a;

            a = 0;
            double axP = 0;
            double axM = 0;
            double ayP = 0;
            double ayM = 0;
            var    finiteElementNodes = new List <RobotFiniteElement>();

            for (var n = 1; n <= objFEs.Count; n++)
            {
                var fe = (RobotFiniteElement)objFEs.Get(n);
                finiteElementNodes.Add(fe);
                a = str.Results.FiniteElems.Reinforcement(slab.Number, fe.Number).AX_BOTTOM;
                if (a > axM)
                {
                    axM = a;
                }
                a = str.Results.FiniteElems.Reinforcement(slab.Number, fe.Number).AX_TOP;
                if (a > axP)
                {
                    axP = a;
                }

                a = str.Results.FiniteElems.Reinforcement(slab.Number, fe.Number).AY_BOTTOM;
                if (a > ayM)
                {
                    ayM = a;
                }
                a = str.Results.FiniteElems.Reinforcement(slab.Number, fe.Number).AY_TOP;
                if (a > ayP)
                {
                    ayP = a;
                }
            }

            //getting results Fx, Fy, Fz, Mx, My, Mz for foot (node 1) with self-weight (case 1)
            txt += "Slab 1, Reinforcemet extreme values:" + "\n\r" + " Ax+ = " + axP * 10000 + " [cm2]" + "\n\r" + " Ax- = " +
                   axM * 10000 + " [cm2]" + "\n\r" + " Ay+ = " + ayP * 10000 + " [cm2]" + "\n\r" + " Ay- = " + ayM * 10000 +
                   " [cm2]" + "\n\r";

            foreach (var fe in finiteElementNodes)
            {
                var nodes = fe.Nodes;
                Console.WriteLine(
                    $"{fe.Number} - {Enumerable.Range(0, nodes.Count).Aggregate("", (x, y) => $"{x} {nodes.Get(y)}")}");
            }


            Console.WriteLine(txt);
        }
示例#21
0
 public bool Connect(RobotApplication robot_app, int add_in_id, bool first_time)
 {
     iapp = robot_app;
     return(true);
 }
 public bool Connect(RobotApplication robot_app, int add_in_id, bool first_time)
 {
     Services.RobotAppService.iapp = robot_app;
     InitAddAssembly();
     return(true);
 }
示例#23
0
        /// <summary>
        /// Gets the FE meshes from a Robot model using the fast query method
        /// </summary>
        /// <param name="panel_ids"></param>
        /// <param name="coords"></param>
        /// <param name="vertex_indices"></param>
        /// <param name="str_nodes"></param>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static bool GetFEMeshQuery(out int[] panel_ids, out double[][] coords, out Dictionary <int, int[]> vertex_indices, string filePath = "LiveLink")
        {
            RobotApplication robot = null;

            if (filePath == "LiveLink")
            {
                robot = new RobotApplication();
            }

            //First call getnodesquery to get node points
            double[][] nodeCoords = null;

            //Dictionary<int, BHoM.Structural.Node> _str_nodes = new Dictionary<int, BHoM.Structural.Node>();
            //RobotToolkit.Node.GetNodesQuery(project, filePath);
            //Dictionary<int, int> _nodeIds = new Dictionary<int, int>();
            //for (int i = 0; i < _str_nodes.Count; i++)
            //{
            //    _nodeIds.Add(_str_nodes.ElementAt(i).Value.Number, i);
            //}

            RobotResultQueryParams      result_params = (RobotResultQueryParams)robot.Kernel.CmpntFactory.Create(IRobotComponentType.I_CT_RESULT_QUERY_PARAMS);
            RobotStructure              rstructure    = robot.Project.Structure;
            RobotSelection              FE_sel        = rstructure.Selections.CreateFull(IRobotObjectType.I_OT_FINITE_ELEMENT);
            IRobotResultQueryReturnType query_return  = IRobotResultQueryReturnType.I_RQRT_MORE_AVAILABLE;
            RobotSelection              cas_sel       = rstructure.Selections.Create(IRobotObjectType.I_OT_CASE);

            try { cas_sel.FromText(robot.Project.Structure.Cases.Get(1).Number.ToString()); } catch { }

            if (cas_sel.Count > 0)
            {
                result_params.Selection.Set(IRobotObjectType.I_OT_CASE, cas_sel);
            }

            //result_params.Selection.Set(IRobotObjectType.I_OT_NODE, FE_sel);

            result_params.SetParam(IRobotResultParamType.I_RPT_MULTI_THREADS, true);
            result_params.SetParam(IRobotResultParamType.I_RPT_THREAD_COUNT, 4);
            result_params.SetParam(IRobotResultParamType.I_RPT_SMOOTHING, IRobotFeResultSmoothing.I_FRS_NO_SMOOTHING);
            result_params.SetParam(IRobotResultParamType.I_RPT_DIR_X_DEFTYPE, IRobotObjLocalXDirDefinitionType.I_OLXDDT_CARTESIAN);
            result_params.SetParam(IRobotResultParamType.I_RPT_DIR_X, new double[] { 1, 0, 0 });

            result_params.SetParam(IRobotResultParamType.I_RPT_NODE, 1);
            result_params.SetParam(IRobotResultParamType.I_RPT_PANEL, 1);
            result_params.SetParam(IRobotResultParamType.I_RPT_ELEMENT, 1);
            result_params.SetParam(IRobotResultParamType.I_RPT_RESULT_POINT_COORDINATES, 1);

            result_params.ResultIds.SetSize(2);
            result_params.ResultIds.Set(1, (int)IRobotFeResultType.I_FRT_DETAILED_MXX);
            result_params.ResultIds.Set(2, (int)IRobotFeResultType.I_FRT_DETAILED_MYY);

            RobotResultRowSet row_set = new RobotResultRowSet();
            bool           ok         = false;
            RobotResultRow result_row = default(RobotResultRow);

            List <int> _panel_ids = new List <int>();
            Dictionary <int, int[]> _vertex_indices = new Dictionary <int, int[]>();
            int kounta = 0;

            while (!(query_return == IRobotResultQueryReturnType.I_RQRT_DONE))
            {
                query_return = rstructure.Results.Query(result_params, row_set);
                ok           = row_set.MoveFirst();
                while (ok)
                {
                    //int panel_num = (int)row_set.CurrentRow.GetValue(1252);
                    //_panel_ids.Add(panel_num);

                    int nodeId = (int)row_set.CurrentRow.GetParam(IRobotResultParamType.I_RPT_NODE);
                    //int panelId = (int)row_set.CurrentRow.GetParam(IRobotResultParamType.I_RPT_PANEL);
                    int elementId = (int)row_set.CurrentRow.GetParam(IRobotResultParamType.I_RPT_ELEMENT);

                    //int number_of_indices = (row_set.CurrentRow.IsAvailable(567)) ? 4 : 3;
                    //int[] temp_indices = new int[number_of_indices];
                    //for (int i = 0; i < number_of_indices; i++)
                    //{
                    //    temp_indices[i] = (int)row_set.CurrentRow.GetValue(564 + i);
                    //}

                    var resultIds = row_set.ResultIds;

                    var xxxx = row_set.CurrentRow.GetParam(IRobotResultParamType.I_RPT_RESULT_POINT_COORDINATES);



                    //_vertex_indices.Add(kounta, temp_indices);
                    //kounta++;
                    ok = row_set.MoveNext();
                }
                row_set.Clear();
            }
            result_params.Reset();

            panel_ids      = _panel_ids.ToArray();
            vertex_indices = _vertex_indices;
            coords         = nodeCoords;
            //str_nodes = _str_nodes;
            return(true);
        }
示例#24
0
        private static void CreateNewProjectWithSlab()
        {
            var robot = new RobotApplication();

            robot.Project.New(IRobotProjectType.I_PT_SHELL);
            robot.Visible = 1;

            var preferences = robot.Project.Preferences;
            var meshParams  = preferences.MeshParams;

            var strt   = robot.Project.Structure;
            var labels = strt.Labels;

            robot.Project.Structure.Nodes.Create(1, 0, 0, 0);
            robot.Project.Structure.Nodes.Create(2, 3, 0, 0);
            robot.Project.Structure.Nodes.Create(3, 3, 3, 0);
            robot.Project.Structure.Nodes.Create(4, 0, 3, 0);

            var points = robot.Kernel.CmpntFactory.Create(IRobotComponentType.I_CT_POINTS_ARRAY) as RobotPointsArray;

            points.SetSize(4);

            points.Set(1, 0, 0, 0);
            points.Set(2, 3, 0, 0);
            points.Set(3, 3, 3, 0);
            points.Set(4, 0, 3, 0);

            var material     = labels.Create(IRobotLabelType.I_LT_MATERIAL, "C30");
            var materialData = material.Data as IRobotMaterialData;

            materialData.Type     = IRobotMaterialType.I_MT_CONCRETE;
            materialData.E        = 30000000000;
            materialData.NU       = 0.2;
            materialData.RO       = 25000;
            materialData.Kirchoff = materialData.E / (2 * (1 + materialData.NU));
            labels.Store(material);

            var label = labels.Create(IRobotLabelType.I_LT_PANEL_THICKNESS, "Slab30");

            if (label.Data is RobotThicknessData thickness)
            {
                thickness.MaterialName  = "C30";
                thickness.ThicknessType = IRobotThicknessType.I_TT_HOMOGENEOUS;
                ((IRobotThicknessHomoData)thickness.Data).ThickConst = 0.3;
            }

            labels.Store(label);

            var slabNumber = strt.Objects.FreeNumber;

            strt.Objects.CreateContour(slabNumber, points);
            RobotObjObject slab = null;

            if (strt.Objects.Get(slabNumber) is RobotObjObject)
            {
                slab = strt.Objects.Get(slabNumber) as RobotObjObject;
                slab.Main.Attribs.Meshed = 1;
                slab.SetLabel(IRobotLabelType.I_LT_PANEL_THICKNESS, "Slab30");
                slab.Initialize();
            }

            var supportLabel = labels.Create(IRobotLabelType.I_LT_SUPPORT, "Footer");
            var footData     = supportLabel.Data as RobotNodeSupportData;

            footData.UX = 1;
            footData.UY = 1;
            footData.UZ = 1;
            footData.RX = 1;
            footData.RY = 1;
            footData.RZ = 1;
            labels.Store(supportLabel);

            var selection = strt.Selections.Get(IRobotObjectType.I_OT_NODE);

            selection.FromText("1 2 3 4");
            strt.Nodes.SetLabel(selection, IRobotLabelType.I_LT_SUPPORT, "Footer");

            var selfWeight = strt.Cases.CreateSimple(1, "SW", IRobotCaseNature.I_CN_PERMANENT,
                                                     IRobotCaseAnalizeType.I_CAT_STATIC_LINEAR);

            selfWeight.Records.New(IRobotLoadRecordType.I_LRT_DEAD);

            var rec = selfWeight.Records.Get(1) as RobotLoadRecord;

            rec.SetValue((short)IRobotBarDeadRecordValues.I_BDRV_ENTIRE_STRUCTURE, 1);
            rec.SetValue((short)IRobotBarDeadRecordValues.I_BDRV_Z, -1);

            var liveLoad = strt.Cases.CreateSimple(2, "Live", IRobotCaseNature.I_CN_EXPLOATATION,
                                                   IRobotCaseAnalizeType.I_CAT_STATIC_LINEAR);
            var uniform = liveLoad.Records.New(IRobotLoadRecordType.I_LRT_UNIFORM);
            var liveRec = liveLoad.Records.Get(uniform) as RobotLoadRecord;

            liveRec.SetValue((short)IRobotUniformRecordValues.I_URV_PX, 0);
            liveRec.SetValue((short)IRobotUniformRecordValues.I_URV_PY, 0);
            liveRec.SetValue((short)IRobotUniformRecordValues.I_URV_PZ, -1000);

            liveRec.Objects.FromText(slabNumber.ToString());

            preferences.SetActiveCode(IRobotCodeType.I_CT_CODE_COMBINATIONS, "BAEL 93");

            robot.Project.CalcEngine.Calculate();

            var nodeResults = robot.Project.Structure.Results.Nodes;

            Console.WriteLine(nodeResults.Reactions.Value(2, 1).FZ);
            Console.WriteLine(nodeResults.Reactions.Value(2, 2).FZ);
            Console.WriteLine(nodeResults.Reactions.Value(2, 3).FZ);
            Console.WriteLine(nodeResults.Reactions.Value(2, 4).FZ);

            var feSelection = strt.Selections.Get(IRobotObjectType.I_OT_FINITE_ELEMENT);

            feSelection.FromText(slab.FiniteElems);
            var feLabels = strt.FiniteElems.GetMany(feSelection);
        }