Robot Structural Analysis Forum
Welcome to Autodesk’s Robot Structural Analysis Forums. Share your knowledge, ask questions, and explore popular Robot Structural Analysis topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

C# API help v3

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
Anonymous
1260 Views, 10 Replies

C# API help v3

I wrote code in c# and I stucked.I pointed in text. Please help me 

1)  loads on cladding   this doesn't add load to the list (on cladding 5 and 6 )

when I open tables/Loads there is  PZ= -66 , List is an empty

2)  doesn't show Table/ bars

3) shows error when debugging

4) error

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using RobotOM;

namespace RobotQ
{
    public partial class Form1 : Form
    {
        private IRobotApplication robApp;
        private RobotProjectPreferences ProjectPrefs;
        private RobotMeshParams MeshParams;
        private IRobotStructure structure;
        private RobotLabelServer labels;
        private IRobotLabel label;
        private RobotSelection SelectionNodes;
        private RobotNodeSupportData footData;
        private IRobotView robotview;
        private IRobotBar bar;
        private IRobotLabel Section;
        private IRobotBarSectionData SData;
        private int TypKod;
        private IRobotCladdingData clad;
        private RobotSelection kontur;

        private RobotLoadRecord LoadRecord;
        private RobotSimpleCase caseSW, DachStale;
        private RobotSimpleCase SniegLewa, SniegPrawa;
        private RobotSimpleCase WiatrLewa, WiatrPrawa, WiatrWzdluz, WiatrWzdluzTyl;
        private RobotSimpleCase Techn;

        private RobotMaterialData Material;
        private RobotObjObject slab;
        private RobotPointsArray points;
        private int ObjNumber;
        private IRobotBarCableData kabel;
        private RobotSelection iselKabelSciana;

        double odHalaSzer; double odHalaWys; double odRozPolacH;
        double aDachKat; double aDachKatD;

        private double x; private double y;
        private string filepath01 = "d:\\test2011.rtd";
        private string filepath02 = "d:\\test03_2011.rtd";
        private string excelpath = "e:\\nauka robot c#\\Lublin\\test03_2011.xlsx";
        private string Stalklasa = "S 355";
        private string StalNosna = "S 235";
        private string Stal2rzedna = "S 235";

        private string StrSlup = "HEA 280";  // nazwy z odstępem
        private string StrRygiel = "HEA 280";
        private string StrSlupBrama = "RK 140x140x5";
        private string StrScianaSrodek = "UPE 120";
        private string StrUsztywn = "HEA 100";

        private string StrPolac = "RK 140x140x5";

        private double odSlupBrama = 1.0;
        private double odBramaLuka = 0.5;
        private double odBramaDol = 0;

        private double odBramaSzer = 4;
        private double odBramaWys = 5;

        private double odHalaWysSlup = 5.5;
        private double odHalaRozstawSlup = 5.5;
        private double odKalenica = 1.75;
        private double odOdsPolac = 0.1;

        private int odLiczbaHal = 5;
        private int liczbaPlatwi = 4;
        private int liczbaRygliScn = 4;
        private double odRygielScnG = 0.3;

        private double obcGpdk = 66;
        private double obcSniegL = 1152; // N/m
        private double obcSniegP = 1283;
        private double obcWtrPlcN = 486;
        private double obcWtrPlcZ = 216;
        private double obcWtrScnN = 378;
        private double obcWtrScnZ = 216;
        private double obcWzdluzWtrPlc = 270;
        private double obcWzdluzWtrScn = 270;

        private double obcWzdluzWtrScnP = 378;
        private double obcWzdluzWtrScnT = 162;
        private double obcTechn = 100;


        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                SetRobot();   
            }
            catch
            {
                MessageBox.Show("Error during initialization");
            }

        }

        private void SetRobot()
        {
            robApp = new RobotApplicationClass();
            // if Robot is not visible
            if (robApp.Visible == 0)   // robApp.Visible = -1
            {
                robApp.Interactive = 1;   // set robot visible and allow user interaction
                robApp.Visible = 1;
            }
            robApp.Project.New(IRobotProjectType.I_PT_FRAME_3D);

            x = 0; y = 0;
            odHalaSzer = 2 * (odSlupBrama + odBramaSzer) + odBramaLuka;
            odRozPolacH = (0.5 * odHalaSzer) / (liczbaPlatwi - 1);
            // aDachKat = Math.Atan(aDachNach * 0.01);  //radiany
            aDachKat = Math.Atan(odKalenica / (0.5 * odHalaSzer));  //radiany

            aDachKatD = (aDachKat * 180) / Math.PI;
            odHalaWys = odHalaWysSlup + 0.5 * odHalaSzer * Math.Tan(aDachKat);        
            
            points.SetSize(5);  // lewa polac  
            points.Set(1, x, y, odHalaWysSlup);
            points.Set(2, x + 0.5 * odHalaSzer, y, odHalaWys);
            points.Set(3, x + 0.5 * odHalaSzer, y + (odLiczbaHal - 1) * odHalaRozstawSlup, odHalaWys);
            points.Set(4, x, y + (odLiczbaHal - 1) * odHalaRozstawSlup, odHalaWysSlup);
            points.Set(5, x, y, odHalaWysSlup);
            ObjNumber = 5;
            structure.Objects.CreateContour(ObjNumber, points);

            points.SetSize(5);  // prawa polac
            points.Set(1, x + odHalaSzer, y, odHalaWysSlup);
            points.Set(2, x + 0.5 * odHalaSzer, y, odHalaWys);
            points.Set(3, x + 0.5 * odHalaSzer, y + (odLiczbaHal - 1) * odHalaRozstawSlup, odHalaWys);
            points.Set(4, x + odHalaSzer, y + (odLiczbaHal - 1) * odHalaRozstawSlup, odHalaWysSlup);
            points.Set(5, x + odHalaSzer, y, odHalaWysSlup);
            ObjNumber = 6;
            structure.Objects.CreateContour(ObjNumber, points);

            Section = structure.Labels.Create(IRobotLabelType.I_LT_CLADDING, "koperta");
            kontur = robApp.Project.Structure.Selections.Get(IRobotObjectType.I_OT_GEOMETRY);
            clad = (IRobotCladdingData)Section.Data;
            clad.Method = IRobotCladdingMethod.I_CM_TRAPEZOIDAL;
            clad.Type = IRobotCladdingType.I_CT_X;
            robApp.Project.Structure.Labels.Store(Section);
            kontur.AddOne(1);             
            structure.Objects.SetStructuralType(Convert.ToString(kontur), IRobotObjectStructuralType.I_OST_WALL);
            structure.Objects.SetLabel(kontur, IRobotLabelType.I_LT_CLADDING, "koperta");

            DachStale = structure.Cases.CreateSimple(2, "DachStale", IRobotCaseNature.I_CN_PERMANENT,
                IRobotCaseAnalizeType.I_CAT_STATIC_LINEAR);
            int UniformDach = DachStale.Records.New(IRobotLoadRecordType.I_LRT_UNIFORM);
            LoadRecord = (RobotLoadRecord)DachStale.Records.Get(UniformDach);

            // 1
            // this doesn't add load to the list (on cladding 5 and 6 )
            // when I open tables/Loads there is  PZ= -66 , List is an empty
            LoadRecord.SetValue(Convert.ToInt16(IRobotUniformRecordValues.I_URV_PX), 0);
            LoadRecord.SetValue(Convert.ToInt16(IRobotUniformRecordValues.I_URV_PY), 0);
            LoadRecord.SetValue(Convert.ToInt16(IRobotUniformRecordValues.I_URV_PZ), -obcGpdk);
            LoadRecord.Objects.AddOne(5); LoadRecord.Objects.AddOne(6);

            // 2
            RobotTable Rtable;
            RobotTableScreenCaptureParams ScPar;
            ScPar = (RobotTableScreenCaptureParams)robApp.CmpntFactory.Create(IRobotComponentType.I_CT_TABLE_SCREEN_CAPTURE_PARAMS);
            ScPar.Name = "Rtable";
            Rtable = robApp.Project.ViewMngr.CreateTable(IRobotTableType.I_TT_BARS, IRobotTableDataType.I_TDT_BAR);
            Rtable.MakeScreenCapture(ScPar);
            // robApp.Project.ViewMngr.NewViewAsTab
            
            // 3
            // RobotNamesArray mtAll = robApp.Project.Preferences.Materials.Get(IRobotMaterialType.I_MT_ALL);

            /*    // 4 it doesn't  work
            IRobotUnitComplexData udm = (IRobotUnitComplexData)robApp.Project.Preferences.Units.Get(IRobotUnitType.I_UT_MOMENT);
            udm.Name = "N";
            udm.Name2 = "m";
            robApp.Project.Preferences.Units.Set(IRobotUnitType.I_UT_MOMENT, (IRobotUnitComplexData)udm);
             
            RobotUnitData test;            
            test.Precision = 4;
            test.Name = "MN";
            robApp.Project.Preferences.Units.Set(IRobotUnitType.I_UT_FORCE, test);   
            */
        }
    }
}

10 REPLIES 10
Message 2 of 11
Anonymous
in reply to: Anonymous

After the line:    robApp.Project.New(IRobotProjectType.I_PT_FRAME_3D);  should be 

          structure = robApp.Project.Structure;
            labels = robApp.Project.Structure.Labels;

Message 3 of 11
Anonymous
in reply to: Anonymous

before points

points = (RobotPointsArray)robApp.CmpntFactory.Create(IRobotComponentType.I_CT_POINTS_ARRAY);

replace  kontur.AddOne(1);   - 

kontur.AddOne(5); kontur.AddOne(6); 

 

Message 4 of 11
Rafal.Gaweda
in reply to: Anonymous

Ad.1 I guess you have selected wrong LoadRecordType

example:

 

            DachStale = structure.Cases.CreateSimple(2, "DachStale", IRobotCaseNature.I_CN_PERMANENT,
                IRobotCaseAnalizeType.I_CAT_STATIC_LINEAR);
            int UniformDach = DachStale.Records.New(IRobotLoadRecordType.I_LRT_UNIFORM);
            LoadRecord = (RobotLoadRecord)DachStale.Records.Get(UniformDach);

            LoadRecord.SetValue(Convert.ToInt16(IRobotUniformRecordValues.I_URV_PX), 0);
            LoadRecord.SetValue(Convert.ToInt16(IRobotUniformRecordValues.I_URV_PY), 0);
            LoadRecord.SetValue(Convert.ToInt16(IRobotUniformRecordValues.I_URV_PZ), -obcGpdk);
            LoadRecord.Objects.AddOne(5); LoadRecord.Objects.AddOne(6);

 

 



Rafal Gaweda
Message 5 of 11
Rafal.Gaweda
in reply to: Rafal.Gaweda

Ad.2

 

            Rtable = robApp.Project.ViewMngr.CreateTable(IRobotTableType.I_TT_BARS, IRobotTableDataType.I_TDT_BAR);

            Rtable.Visible = 1;

 



Rafal Gaweda
Message 6 of 11
Rafal.Gaweda
in reply to: Rafal.Gaweda

Ad.3 Example, polish material database contains 10 Concrete materials so:

 

             RobotNamesArray mtAll = new RobotNamesArray();
             mtAll.SetSize(10);
             mtAll    = robApp.Project.Preferences.Materials.Get(IRobotMaterialType.I_MT_CONCRETE);

 



Rafal Gaweda
Message 7 of 11
Rafal.Gaweda
in reply to: Rafal.Gaweda

Ad 4

 

            IRobotUnitComplexData udm = (RobotUnitComplexData)robApp.Project.Preferences.Units.Get(IRobotUnitType.I_UT_MOMENT);
            udm.Name = "N";
            udm.Name2 = "m";

            robApp.Project.Preferences.Units.Set(IRobotUnitType.I_UT_MOMENT, (RobotUnitData)udm);

            RobotUnitData test = robApp.Project.Preferences.Units.Get(IRobotUnitType.I_UT_FORCE);           
            test.Precision = 4;
            test.Name = "MN";
            robApp.Project.Preferences.Units.Set(IRobotUnitType.I_UT_FORCE, test); 

 



Rafal Gaweda
Message 8 of 11
Anonymous
in reply to: Rafal.Gaweda

Ad1  I created,

 it returned error konturObc.SetContourPoint(1, 10, 20,0);  I don't know why 

 

            RobotLoadRecordInContour konturObc;
            DachStale = structure.Cases.CreateSimple(2, "DachStale", IRobotCaseNature.I_CN_PERMANENT,
                IRobotCaseAnalizeType.I_CAT_STATIC_LINEAR);
            int UniformDach = DachStale.Records.New(IRobotLoadRecordType.I_LRT_IN_CONTOUR);
            konturObc = (RobotLoadRecordInContour)DachStale.Records.Get(UniformDach);
            konturObc.Objects.AddOne(5);
            konturObc.Objects.AddOne(6);

            konturObc.SetValue(Convert.ToInt16(IRobotInContourRecordValues.I_ICRV_PX1), 0);
            konturObc.SetValue(Convert.ToInt16(IRobotInContourRecordValues.I_ICRV_PX2), 0);
            konturObc.SetValue(Convert.ToInt16(IRobotInContourRecordValues.I_ICRV_PX3), 0);

            konturObc.SetValue(Convert.ToInt16(IRobotInContourRecordValues.I_ICRV_PY1), 0);
            konturObc.SetValue(Convert.ToInt16(IRobotInContourRecordValues.I_ICRV_PY2), 0);
            konturObc.SetValue(Convert.ToInt16(IRobotInContourRecordValues.I_ICRV_PY3), 0);


            konturObc.SetValue(Convert.ToInt16(IRobotInContourRecordValues.I_ICRV_PZ1), -obcGpdk);
            konturObc.SetValue(Convert.ToInt16(IRobotInContourRecordValues.I_ICRV_PZ2), -obcGpdk);
            konturObc.SetValue(Convert.ToInt16(IRobotInContourRecordValues.I_ICRV_PZ3), -obcGpdk);
            konturObc.SetValue(Convert.ToInt16(IRobotInContourRecordValues.I_ICRV_PROJECTION), 1);
            konturObc.SetValue(Convert.ToInt16(IRobotInContourRecordValues.I_ICRV_LOCAL), 0);

            // konturObc.GetContourPoint
            konturObc.SetVector(0, 0, 1);
            konturObc.SetPoint(1, 0, 0, 0);
            konturObc.SetPoint(2, 1, 1, 0);
            konturObc.SetPoint(3, 1, 0, 0);

            konturObc.SetContourPoint(1, 10, 20,0);

 

Ad 2 it doesn't work but it should ,  robot 2011

          Rtable = robApp.Project.ViewMngr.CreateTable(IRobotTableType.I_TT_BARS, IRobotTableDataType.I_TDT_BAR);
            Rtable.Visible = 1;

 

Message 9 of 11
Rafal.Gaweda
in reply to: Anonymous

Ad.1 Example: contour with 3 points below, 13 <=  I_ICRV_NPOINTS

 

 

            konturObc.SetValue(13, 3);
            konturObc.SetContourPoint(1, 10, 20, 0);
            konturObc.SetContourPoint(2, 0, 20, 0);
            konturObc.SetContourPoint(3, 20, 20, 0);

 



Rafal Gaweda
Message 10 of 11
Rafal.Gaweda
in reply to: Anonymous

 

Ad 2 it doesn't work but it should ,  robot 2011

 

I have 2013.

Try to add column to table.

 



Rafal Gaweda
Message 11 of 11
Anonymous
in reply to: Rafal.Gaweda

Thank You for help

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report