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: 

API - get load combination properties

19 REPLIES 19
SOLVED
Reply
Message 1 of 20
Mirko.Jurcevic
1910 Views, 19 Replies

API - get load combination properties

Hi,

I am trying to get code combination properties, but I can't get it, i've made this so far:

 

public partial class Form1 : Form
{
     IRobotCaseServer Loads;
     RobotCaseCollection RCC;

 

     private void Form1_Load(object sender, EventArgs e) {
          Robot.robApp = new RobotApplication();
          Loads = Robot.robApp.Project.Structure.Cases;
          RCC = Loads.GetAll();

          for (int j = 1; j <= RCC.Count; j++) {
                 IRobotCase rc = RCC.Get(j);
                 IRobotCaseAnalizeType AT = rc.AnalizeType;
                 if (AT == IRobotCaseAnalizeType.I_CAT_COMB || AT == IRobotCaseAnalizeType.I_CAT_COMB_CODE || AT == IRobotCaseAnalizeType.I_CAT_COMB_NONLINEAR) {

                 //IRobotCaseCombination RComb = RCC.Get(j); //this doesn't work
                 IRobotCaseCombination RComb = RCC.Get(j) as IRobotCaseCombination; //this doesn't work also

                 textBox1.Text += rc.Number + " " + rc.Name + "\r\n";
                 textBox1.Text += RComb.label + "\r\n"; //this doesn't work, loop breaks here
                 // textBox1.Text += RCC.Get(j).label + "\r\n"; //this doesn't work also
        }
    }
}

 

But this code seem to work in excel. I don't understand. Here is the main problem:

RobotCaseCombination RComb = RCC.Get(j);

it won't accept it.

 

and this line returns null reference:

IRobotCaseCombination RComb = RCC.Get(j) as IRobotCaseCombination;

 

any idea?

If this solved your issue, please Accept it as Solution help other forum users with similar issues to find answers easily.
  
Mirko Jurcevic


My blog: www.engipedia.com
Try my Revit add-ins: Autodesk App Store
19 REPLIES 19
Message 2 of 20

Because code combinations are not combinations

 

                    RobotCodeCmbCombs RCombs = RCC.Get(j);
                    for (int ii = 1; ii <= RCombs.Count; ii++)
                    {
                        RobotCodeCmbComponent RC = RCombs.Get(ii,........);

 



Rafal Gaweda
Message 3 of 20

I know that I've been missing something, thanks Rafal, but that's not working either.

I've tried this:

RobotCodeCmbCombs Combinations = RCC.Get(j);
textBox1.Text += Combinations.Count.ToString() + "\r\n";

 and this:

RobotCodeCmbCombs Combinations = RCC.Get(j) as RobotCodeCmbCombs;
textBox1.Text += Combinations.Count.ToString() + "\r\n";

 and this:

IRobotCodeCmbCombs Combinations = RCC.Get(j) as IRobotCodeCmbCombs;
textBox1.Text += Combinations.Count.ToString() + "\r\n";

 but code breaks at this line: 

IRobotCodeCmbCombs Combinations = RCC.Get(j) as IRobotCodeCmbCombs;

 By breaking, I mean it keeps running but it does nothing.

If this solved your issue, please Accept it as Solution help other forum users with similar issues to find answers easily.
  
Mirko Jurcevic


My blog: www.engipedia.com
Try my Revit add-ins: Autodesk App Store
Message 4 of 20

MIrko

 

are you sure Get(j) returns codecombination and not manual combination ?

 

try switch:

 

switch (AT)
{
case IRobotCaseAnalizeType.I_CAT_COMB:
IRobotCaseCombination RComb ...
break;
case IRobotCaseAnalizeType.I_CAT_COMB_CODE 
RobotCodeCmbCombs RCombs ......

 



Rafal Gaweda
Message 5 of 20

I have 0 manual combinations.

It still doesn't work.

I have this:

RobotCaseCollection RCC = Robot.robApp.Project.Structure.Cases.GetAll();

for (int j = 1; j <= RCC.Count; j++) {
	IRobotCase rc = RCC.Get(j);
	IRobotCaseAnalizeType AT = rc.AnalizeType;
	
        switch (AT) {
		case IRobotCaseAnalizeType.I_CAT_COMB:
			textBox1.Text += "not a code combination";
			break;
		case IRobotCaseAnalizeType.I_CAT_COMB_CODE:
			textBox1.Text += "i'm in";	//this is printed only once
		RobotCodeCmbCombs Combinations = RCC.Get(j) as RobotCodeCmbCombs;
		textBox1.Text += Combinations.Count.ToString() + "\r\n";
		break;
	}
}

 I am not sure if this is ok:

RobotCaseCollection RCC = Robot.robApp.Project.Structure.Cases.GetAll();

 

If this solved your issue, please Accept it as Solution help other forum users with similar issues to find answers easily.
  
Mirko Jurcevic


My blog: www.engipedia.com
Try my Revit add-ins: Autodesk App Store
Message 6 of 20

My mistake, sorry.

Correct code:

 

RobotCaseCollection RCC = Loads.GetAll();

          for (int j = 1; j <= RCC.Count; j++)
          {
            IRobotCase RC = RCC.Get(j);
            IRobotCaseAnalizeType AT = RC.AnalizeType;
            if (AT == IRobotCaseAnalizeType.I_CAT_COMB || AT == IRobotCaseAnalizeType.I_CAT_COMB_CODE || AT == IRobotCaseAnalizeType.I_CAT_COMB_NONLINEAR)
            {
              RobotCodeCombination c = RCC.Get(j);
              MessageBox.Show(c.Number.ToString() + " " + c.Name);
              RobotCodeCmbComponentMngr RCombs = c.Components; 
              for (int ii = 1; ii <= RCombs.Count; ii++)
              {
                IRobotCodeCmbComponent RComp = RCombs.Get(ii);
                for (int jj = 1; jj <= RComp.Count; jj++)
                {
                  RobotCodeCmbFactor factor = RComp.Get(jj);
                  string cn = factor.CaseNumber.ToString();
                  string fc = factor.Factor.ToString();
                  MessageBox.Show(cn + " " + fc);
                }
                //textBox7.Text += RC.Number.ToString();
              }
            }
          }

 



Rafal Gaweda
Message 7 of 20

Yes, it works !!

Thank you Rafal, very much. It would took me several days to figure it out myself !

😄

 

Cheers!

If this solved your issue, please Accept it as Solution help other forum users with similar issues to find answers easily.
  
Mirko Jurcevic


My blog: www.engipedia.com
Try my Revit add-ins: Autodesk App Store
Message 8 of 20

Eh, another problem I have now...  Smiley Indifferent

 

What in case I have moving load in combinations?

I have it and I get '0' for case number (cn variable) in such case:

for this: 1*1.35 + 3*0.90 + 4*0.75 + 5/12*1.50

I get this: 1*1.35 + 3*0.90 + 4*0.75 + 0*1.50

etc.

 

What I want to do is get load definition for all cases, then replace those case numbers with case labels (for my custom report application).

If this solved your issue, please Accept it as Solution help other forum users with similar issues to find answers easily.
  
Mirko Jurcevic


My blog: www.engipedia.com
Try my Revit add-ins: Autodesk App Store
Message 9 of 20

Most likely moving load cases not implemented there.
We will check tomorrow.


Rafal Gaweda
Message 10 of 20

Is there any other way to get combination definition "sentence"?

Because, that's all I need.

If this solved your issue, please Accept it as Solution help other forum users with similar issues to find answers easily.
  
Mirko Jurcevic


My blog: www.engipedia.com
Try my Revit add-ins: Autodesk App Store
Message 11 of 20

If you mean "Definition" - Definition column in Combinations table : try to open Combinations table (by API), set display of code combinations, (maybe set case also) then save to text file \ csv then read this file in your program.


Rafal Gaweda
Message 12 of 20

Yes, I've already tried this, I managed to open table but I didn't know how to get data from table rows.

Can I somehow "copy" data from table "Definition" column (I mean without saving as txt or csv file)?

I not, how to save it to txt through api?

If this solved your issue, please Accept it as Solution help other forum users with similar issues to find answers easily.
  
Mirko Jurcevic


My blog: www.engipedia.com
Try my Revit add-ins: Autodesk App Store
Message 14 of 20

Thanks Rafal !

I shall try to adjust it for my app.

If this solved your issue, please Accept it as Solution help other forum users with similar issues to find answers easily.
  
Mirko Jurcevic


My blog: www.engipedia.com
Try my Revit add-ins: Autodesk App Store
Message 15 of 20

Rafal, this is great stuff.

C# code is pretty simple, I'll post it here, maybe it help someone else:

using System;
using System.IO;

private void Save_Table() {
	string FolderName = "Intelika";

	IRobotTable RT = Robot.robApp.Project.ViewMngr.CreateTable(IRobotTableType.I_TT_COMBINATIONS, IRobotTableDataType.I_TDT_CODE_GROUPS);

	/*** path to desktop: ***/
	string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
	path += "\\" + FolderName;

	if (!Directory.Exists(path))	/*** if directory doesn't exists -> create it ***/
	{
		Directory.CreateDirectory(path);				
	}

	RT.Printable.SaveToFile(path + "\\temp.html", IRobotOutputFileFormat.I_OFF_HTML);	/*** SAVE AS HTML ***/
	RT.Printable.SaveToFile(path + "\\temp.txt", IRobotOutputFileFormat.I_OFF_TEXT);	/*** SAVE AS TXT ***/
}

I didn't know about this SaveToFile() method before.

This approach is much much faster than reading combinations directly from Robot. Good to know!

 

But, as always, I have yet another question.  😉

Now that I've opened and exploited Robot's table, can I somehow close it through api?

 

I don't want 20 tables opened in Robot every time I extract some data.  😞

If this solved your issue, please Accept it as Solution help other forum users with similar issues to find answers easily.
  
Mirko Jurcevic


My blog: www.engipedia.com
Try my Revit add-ins: Autodesk App Store
Message 16 of 20

Check this example:

 

RobotTableFrame tf = robApp.Project.ViewMngr.GetTable(1); 
          tf.Window.SendMessage(0x0010,0,0) ;

OR

 

RobotTable RT = robApp.Project.ViewMngr.GetTable(1); 
          RT.Window.SendMessage(0x0010,0,0) ;

 

 

 In VB, VBA:

 

RT.Window.SendMessage 16, 0, 0

 



Rafal Gaweda
Message 17 of 20

Yep, it works!

Very nice, thanks!

😄

If this solved your issue, please Accept it as Solution help other forum users with similar issues to find answers easily.
  
Mirko Jurcevic


My blog: www.engipedia.com
Try my Revit add-ins: Autodesk App Store
Message 18 of 20

RobotTable RT = robApp.Project.ViewMngr.GetTable(1);

RT.Window.SendMessage(0x0010,0,0) ;

Visual studio complains: "Cannot implicitly convert RobotTable to RobotTableFrame" or something like that

 

And I must comment this code:

RobotTableFrame tf = robApp.Project.ViewMngr.GetTable(1); 
          tf.Window.SendMessage(0x0010,0,0);

Very dangerous if you run this code in some view where you have tables opened (for example in "Loads" interface you have Load table opened by default and user cannot close it, but API can), it closes first table it finds, and that can be some other table than the one API opened.

 

I've programmed to find last opened table.

This works fine:

int numOfTables = Robot.robApp.Project.ViewMngr.TableCount;
IRobotTableFrame tf = Robot.robApp.Project.ViewMngr.GetTable(numOfTables);						
tf.Window.SendMessage(0x0010, 0, 0);

 

If this solved your issue, please Accept it as Solution help other forum users with similar issues to find answers easily.
  
Mirko Jurcevic


My blog: www.engipedia.com
Try my Revit add-ins: Autodesk App Store
Message 19 of 20

Dim RT As RobotTable
Dim RTF As RobotTableFrame
Set RTF = Robapp.Project.ViewMngr.GetTable(1)

Set RT = RTF.Get(1)

 



Rafal Gaweda
Message 20 of 20

That's cheating  😉

If this solved your issue, please Accept it as Solution help other forum users with similar issues to find answers easily.
  
Mirko Jurcevic


My blog: www.engipedia.com
Try my Revit add-ins: Autodesk App Store

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

Post to forums  

Autodesk Design & Make Report