GET ENVELOPE FORCES BAR VIA API (C#)

GET ENVELOPE FORCES BAR VIA API (C#)

eng_leandromartins
Advocate Advocate
1,682 Views
8 Replies
Message 1 of 9

GET ENVELOPE FORCES BAR VIA API (C#)

eng_leandromartins
Advocate
Advocate

Hello everyone,

How do I get the envelope of all combinations from the beginning and end of each bar?

I wrote the code below but it goes through all combinations and all bars. It takes too long.

I saw several examples on the forum, but I didn't quite understand the logic applied.

 

 

 

 public List<InternalForces> GetInternalForces()
 {
     
     List<double> FX = new List<double>();
     RobotCaseCollection caseCollection = new RobotCaseCollection();
     rSelection = RobotApp.Project.Structure.Selections.Create(IRobotObjectType.I_OT_CASE);
     ForceServer = RobotApp.Project.Structure.Results.Bars.Forces;
     rSelection.AddText("todos");
     caseCollection = RobotApp.Project.Structure.Cases.GetMany(rSelection);

     if (RobotApp.Project.Structure.Results.Available == -1 )
     {

         for (int i = 0; i < OrdenadesProfiles.Count; i++)
         {


             for (int j = 1; j < caseCollection.Count; j++)
             {

                 if (CaseType == IRobotCaseAnalizeType.I_CAT_COMB || CaseType == IRobotCaseAnalizeType.I_CAT_COMB_CODE || CaseType == IRobotCaseAnalizeType.I_CAT_COMB_NONLINEAR)
                 {

                     robotCase = caseCollection.Get(j);
                     int casNumber = robotCase.Number;
                     DataForce = ForceServer.Value(OrdenadesProfiles[i].Number, casNumber, 0.0);
                     FX.Add(DataForce.FX);
                     DataForce = ForceServer.Value(OrdenadesProfiles[i].Number, casNumber, 1.0);
                     FX.Add(DataForce.FX);

                 }
             }

         BarNumber = OrdenadesProfiles[i].Number;
             FXMax = FX.Max();
             FXMin = FX.Min();
         }

         internalForces.Add(new InternalForces(BarNumber,FXMax, FXMin));

     }
     else
     {
         MessageBox.Show("Modelo sem Resultados!","AVISO",MessageBoxButtons.OK);

     }
     return internalForces;
 }

 

Thanks in advance

0 Likes
Accepted solutions (2)
1,683 Views
8 Replies
Replies (8)
Message 2 of 9

Stephane.kapetanovic
Mentor
Mentor
Accepted solution

HI @eng_leandromartins 

you should read this topic (msg 15): (API) Macro for dumping all opened tables in Robot (with all tabs) to Excel 

note that you can change IRobotTableDataType.I_TDT_DEFAULT to I_TDT_ENVELOPE in Sub GetBarForcesByTable 

static void GetBarForceEnvelopeByTable(string bText, string cText, int n) {
    var tb = new RobotApplication().Project.ViewMngr.CreateTable(I_TT_FORCES, I_TDT_ENVELOPE);
    tb.Select(I_ST_BAR, bText); tb.Select(I_ST_CASE, cText); tb.Configuration.SetValue(I_TCV_NUMBER_OF_DIVISION_POINTS, n);
    string fullPath = Path.Combine(Path.GetTempPath(), "forces.txt");
    if (tb.Printable.SaveToFile(fullPath, I_OFF_TEXT))
        File.ReadAllLines(fullPath).Skip(1).Select(line => string.Concat(line.Split(';').Select(s => $"{s,-15}"))).ToList().ForEach(WriteLine);
    tb.Window.SendMessage(0x10, 0, 0); WriteLine("Press any key to continue..."); ReadKey();
}

Best regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to click the Accept Solution button and leave a < like !
EESignature
0 Likes
Message 3 of 9

eng_leandromartins
Advocate
Advocate

Thanks for the answer Stephane,

One question, how do I create a List through this?

I don't want to save this information in any file. I want to create a List and get this information in another method.

 

0 Likes
Message 4 of 9

Hi @eng_leandromartins 

Have you tried the code?
The code does the following:
- creates a table of envelope forces in robot
- exports the table in csv format and closes it
- opens the file and reads it in its entirety
- it displays all the values by column in console mode
With this you have everything you need to create lists, sort and classify your data.
It's not just a file output. this is a normal process.

Why create a list? Which one? What's it for? I can't guess what you want to do.

 

Best Regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to click the Accept Solution button and leave a < like !
EESignature
0 Likes
Message 5 of 9

eng_leandromartins
Advocate
Advocate

Hello,
I tested it, and I realized that the best way to do what I need is to use this file that this method generates and create a list through it.
Sorry for not making it clear what I want to do @Stephane.kapetanovic 
I created an app that uses Robot information to create a model within Tekla Structures, and I want to put this force information inside the parts that are created within Tekla, as user information! And the best way to do this is through a list of parts. So I thought about creating a List directly with the Robot information. But as you showed me, the best way is through this file.
Thanks again!!!

Message 6 of 9

hi @eng_leandromartins 

In this case you should add the object IDs of your two models to this list so that you can update your data.

note that you can obtain a list of forces in csv format without using the API.

Best Regards

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to click the Accept Solution button and leave a < like !
EESignature
0 Likes
Message 7 of 9

eng_leandromartins
Advocate
Advocate

Thanks for the tip about the IDs @Stephane.kapetanovic!
Do you have a tutorial on how to create or get these IDs in Robot?

0 Likes
Message 8 of 9

Accepted solution
     RobotApplication RobApp = new RobotApplication();
    RobotStructure Structure = RobApp.Project.Structure;
       RobotNodeServer Nodes = Structure.Nodes;
         RobotBarServer Bars = Structure.Bars;
RobotObjObjectServer Objects = Structure.Objects;

     RobotNode n = (RobotNode)Nodes.Get(1);        int Nod_ID = n.UniqueId;
      RobotBar b = (RobotBar)Bars.Get(1);          int Bar_ID = b.UniqueId;
RobotObjObject o = (RobotObjObject)Objects.Get(1); int Obj_ID = o.UniqueId;

int Nod_Number = Nodes.GetUniqueId(Nod_ID);        RobotNode n1 = (RobotNode)Nodes.Get(Nod_Number);
int Bar_Number = Bars.GetUniqueId(Bar_ID);          RobotBar b1 = (RobotBar)Bars.Get(Bar_Number);
int Obj_Number = Objects.GetUniqueId(Obj_ID); RobotObjObject o1 = (RobotObjObject)Objects.Get(Obj_Number); 

Stéphane Kapetanovic

Did you find this post helpful? If it gave you one or more solutions,
don't forget to click the Accept Solution button and leave a < like !
EESignature
0 Likes
Message 9 of 9

eng_leandromartins
Advocate
Advocate

Thank's so much!