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?
Solved! Go to Solution.
Solved by Rafal.Gaweda. Go to Solution.
Solved by Rafal.Gaweda. Go to Solution.
Because code combinations are not combinations
RobotCodeCmbCombs RCombs = RCC.Get(j); for (int ii = 1; ii <= RCombs.Count; ii++) { RobotCodeCmbComponent RC = RCombs.Get(ii,........);
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.
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 ......
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();
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(); } } }
Yes, it works !!
Thank you Rafal, very much. It would took me several days to figure it out myself !
😄
Cheers!
Eh, another problem I have now...
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).
Is there any other way to get combination definition "sentence"?
Because, that's all I need.
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?
I not, how to save it to txt through api?
http://forums.autodesk.com/t5/Robot-Structural-Analysis/API-Exporting-modal-harmonic-load-case-getti...
http://forums.autodesk.com/t5/Robot-Structural-Analysis/ROBOT-API-VBA-Panel-cuts-and-table-generatio...
Thanks Rafal !
I shall try to adjust it for my app.
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. 😞
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
Yep, it works!
Very nice, thanks!
😄
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);
Dim RT As RobotTable Dim RTF As RobotTableFrame Set RTF = Robapp.Project.ViewMngr.GetTable(1) Set RT = RTF.Get(1)
That's cheating 😉