I am using c# and i have basically replicated the exact code from the tutorial "Define the model with finite elements" and translated it into c# however when the code reaches the line:
IRobotNumbersCollection col = robApp.Project.Structure.Objects.CreateOnFiniteElems("1to20", 1);
it will crash robot, if i use
IRobotNumbersCollection col = robApp.Project.Structure.Objects.CreateOnFiniteElems(allFE.ToString(), 1);
it seems that it simply skips the line.
Below is the entire code, it is very short, basically just what was given in the tutorial. Any ideas as to why it is crashing would help me immensely.
RobotApplication robApp;
robApp = new RobotApplication();
robApp.Visible =1;
robApp.Project.New(IRobotProjectType.I_PT_SHELL);
RobotProjectPreferences ProjectPrefs;
ProjectPrefs = robApp.Project.Preferences;
ProjectPrefs.SetActiveCode(IRobotCodeType.I_CT_RC_THEORETICAL_REINF, "BAEL 91");
IRobotStructure str;
str = robApp.Project.Structure;
IRobotNodeServer nod = robApp.Project.Structure.Nodes;
double k = 0;
for(int i = 0;i<8;i++){
nod.Create (1 + i * 10, 0, 0, 0+k) ;
nod.Create (2 + i * 10, 0.5, 0,0+k) ;
nod.Create (3 + i * 10, 1, 0, 0+k) ;
nod.Create (4 + i * 10, 1.5, 0, 0+k) ;
nod.Create (5 + i * 10, 2, 0, 0+k) ;
//nod.Create (6 + i * 10, 2.5, 0, 0+k) ;
k = k + 0.5;
}
IRobotFiniteElementServer fe_serv = robApp.Project.Structure.FiniteElems;
RobotNumbersArray[] arr = new RobotNumbersArray[4];
for(int i = 0;i<7;i++){
for(int j = 0;j<4;j++){
arr[j]= new RobotNumbersArray();
arr[j].SetSize(4);
arr[j].Set(1, 1 + j + 10 * i);
arr[j].Set(2, 2 + j + 10 * i);
arr[j].Set(3, 12 + j + 10 * i);
arr[j].Set(4, 11 + j + 10 * i);
fe_serv.Create( 1 + 10 * j + i, arr[j], false);
}
}
fe_serv.Update();
IRobotSelection allFE = robApp.Project.Structure.Selections.CreateFull(IRobotObjectType.I_OT_FINITE_ELEMENT);
IRobotNumbersCollection col = robApp.Project.Structure.Objects.CreateOnFiniteElems("1to20", 1);//Crashes here
//IRobotNumbersCollection col = robApp.Project.Structure.Objects.CreateOnFiniteElems( allFE.ToString(), 1);//or here
Thank you.
I can't see any problem with this code and it runs correctly during our tests. What is the exact version of Robot you use and what is the system on your machine?
i am running robot2011(x86) on win 7 64. So you are saying that the code posted above is working for you?
Ok i have realized my problem, but i don't know if there is a solution. It is not a problem of the version but a problem of ordering. Is it necessary to load all of the elements that one wishes to create a plate from into CreateOnFiniteElems in order? I am generating my own meshes and i do not know the order of the elements, is there a way to have the element server order them for you, similar to the way it does in the interface?
I think that in fact this issue is linked with the v.2011 version of Robot you are using which apparently has got some limitation in handling this code. The test we made on the v.2012 version show that there is no problem with running it.
If you find your post answered press the Accept as Solution button please. This will help other users to find solutions much faster. Thank you.
I was able to get the code i had previously posted to run by adding a try catch procedure around the "CreateOnFiniteElems" call as follows:
try
{
IRobotNumbersCollection col = robApp.Project.Structure.Objects.CreateOnFiniteElems(allFE.ToText(), 1);
}
catch (System.Runtime.InteropServices.COMException)
{
}
but if i enter the elemetns in the wrong order it will still crash, for example:
List<RobotNumbersArray> fullarr = new List<RobotNumbersArray>();
for (int i = 0; i < 7; i++)
{
for (int j = 0; j < 4; j++)
{
RobotNumbersArray arr = new RobotNumbersArray();
arr.SetSize(4);
arr.Set(1, 1 + j + 10 * i);
arr.Set(2, 2 + j + 10 * i);
arr.Set(3, 12 + j + 10 * i);
arr.Set(4, 11 + j + 10 * i);
fullarr.Add(arr);
}
}
//reordering elements//
RobotNumbersArray arrt = fullarr[3];
fullarr[3] = fullarr[5];
fullarr[5] = arrt;
arrt = fullarr[10];
fullarr[10] = fullarr[12];
fullarr[12] = arrt;
for (int i = 0; i < fullarr.Count; i++)
{
fe_serv.Create(i + 1, fullarr[i], false);
}
Any Ideas?
Would it be possible for you to install the 30 day trial version of Robot 2012 and check on the same example please?
http://usa.autodesk.com/adsk/servlet/oc/offer/form?siteID=123112&id=13387025
I tried to download and install the 2012 release but for some reason the only component that doesn't install is the SDK after 2 attempts i have given up on the 2012 version. So in the end i am not able to consolidate the imported elements to a panel object. But i assume that using finite elements as they are without consolidating them would yield the same results? When further researching this possibility i have found that this is not true. I have attached a modified version of "Plate.str" which comes with robot as an example file. When i solve the problem as it is imported i get different results than if i create a plate object from the elements. What is happening here? Is it necessary to have plate objects rather than simply running the analysis on a set of quad/tri elements with assigned properties?
The str format in not the native one for ARSA(P) and it doesn't have syntax for all attributes and objects that are currently used. It is the format that originates from its older DOS predecessor named Robot V6. The main difference is that in the DOS program the attributes were directly assigned to surface elements directly (panels as objects did not exist) whereas now they are applied to panels instead. It is the model generation which 'transfers' this data (loads, thickness, material etc.) from a panel to surface elements created within this panel.
For installation of SDK on 64-bit systems see http://forums.autodesk.com/t5/Autodesk-Robot-Structural/About-the-SDK-application-for-Optimization-u...
I understand that there is not nearly as much functionality in the .str format. But for the time being it seems that the only option for me is to continue using the str format since it is the only format in which i can import my own fea mesh and assign properties to the elements. I have tried many things over the last week trying to get my meshes into robot and run accurate tests on them. One problem i found was when importing meshes with the api was that dead loads would not recognize the physical properties of mesh elements if they were not consolidated into panels, but when importing a str file the elements would be recognized. Another strange bit of behavior is when importing a mesh using the api and then running a analysis on it(without consolidating it into a panel) with no load cases defined a deadload case would automatically appear but would only run once, after that it would recognize the elements as having 0 mass. When running the CreateOnFiniteElems command in c++ it will work intermittently, sometimes 10 times in a row before crashing, leading me to believe that there is a memory leak somewhere. Please continue to support the .str format just as a precaution, i very much appreciate its simplicity and portability.
Could you check if you can create a panel using the Panel dialog after selecting the same list of surface elements as the one you provided for your API code please? Have you managed to check your API code on v.2012?
no i have not been able to check it on the 2012 api, since what i am doing may require older versions of robot. I need to have an unquestionably stable approach. Yes when creating a panel using the interface it works every time.
Hello,
I am still not able to solve my previous problem. There seems to be no unconditionally stable and accurate method for creating shells from the api, at least not in the 2011 x86 version. So I have had some time over the last couple of days to go back and try again with the command CreateOnFiniteElems. I use the following code for testing.
RobotApplication robApp;
robApp = new RobotApplication();
robApp.Visible = 1;
robApp.Project.New(IRobotProjectType.I_PT_SHELL);
IRobotNodeServer nod = robApp.Project.Structure.Nodes;
double k = 0;
for (int i = 0; i < 8; i++)
{
nod.Create(1 + i * 10, 0, 0, 0 + k);
nod.Create(2 + i * 10, 0.5, 0, 0 + k);
nod.Create(3 + i * 10, 1, 0, 0 + k);
nod.Create(4 + i * 10, 1.5, 0, 0 + k);
nod.Create(5 + i * 10, 2, 0, 0 + k);
k = k + 0.5;
}
IRobotFiniteElementServer fe_serv = robApp.Project.Structure.FiniteElems;
RobotNumbersArray[] arr = new RobotNumbersArray[4];
for (int i = 0; i < 7; i++)
{
for (int j = 0; j < 4; j++)
{
arr[j] = new RobotNumbersArray();
arr[j].SetSize(4);
arr[j].Set(1, 1 + j + 10 * i);
arr[j].Set(2, 2 + j + 10 * i);
arr[j].Set(3, 12 + j + 10 * i);
arr[j].Set(4, 11 + j + 10 * i);
fe_serv.Create(1 + 10 * j + i, arr[j], false);
}
}
fe_serv.Update();
RobotSelection allFE = robApp.Project.Structure.Selections.CreateFull(IRobotObjectType.I_OT_FINITE_ELEMENT);
RobotNumbersCollection col;
try
{
col = robApp.Project.Structure.Objects.CreateOnFiniteElems(allFE.ToText(), 1);
}
catch (System.Runtime.InteropServices.COMException e)
{
MessageBox.Show(e.Message.ToString());
}
The funny thing about this is that i can run it and it will work 10 times in a row and then on the 11th time it will crash. Additionally, every time that it is run I catch the exception "HRESULT E_FAIL has been returned from the com component" regardless of if the program then crashes or not. If i replace "allFE.ToText()" with "allFE.ToString()" the program will not catch an error, but it will also not create a panel, in this case nothing happens....
I am looking for a solution for this problem that will work with all versions of Robot. Are you planning on releasing a service pack or something along those lines to fix this for older versions of Robot, or will all improvements be exclusive to future releases? I have tried creating finite elements using the api and i have tried using a text file, neither of them seem to allow me to create panels, nor do the results from the finite elements appear to be accurate. Any help or advice on getting a stable method working with all versions of Robot would be greatly appreciated. Any Ideas??
The changes and improvements in the API are done for the current (last released) and next versions of Robot.
well i finally have tested with the 2012 version and everything seems to work in that version but that leaves all of the previous version users behind...
I'm very pleased that you finally decided to test the current version of Robot. Of course it would be great to update all older versions of Robot with all the changes and improvements done for the new ones but in the real world this is obviously for many reasons not possible.
If you find your post answered press the Accept as Solution button please. This will help other users to find solutions much faster. Thank you.
Hi,
I have created a series of finite element meshes, however want to convert them to a single panel/contour, as I am able to do through the GUI by selecting the surface objects as an FE list. Is this possible to do via the API? I then want to assign material properties to the panel.
I have printed below, what I have got so far, however this only creates single panel elements for individual FE objects. Your help is much appreciated!
Dim FEServer As IRobotFiniteElementServer
Dim MyArr As RobotNumbersArray
FEServer.Create(FENum, MyArr, False)
FEServer.Update
Dim AllFE As RobotSelection
Dim SelType As IRobotObjectType
SelType = IRobotObjectType.I_OT_FINITE_ELEMENT
AllFE = MyRobot.Selections.CreateFull(SelType)
Dim Collection As RobotNumbersCollection
Collection = MyRobot.Objects.CreateOnFiniteElems(AllFE.ToText(), 1)
Hi
I have created a series of finite element meshes, however want to convert them to a single panel/contour,........
I have printed below, what I have got so far, however this only creates single panel elements for individual FE objects. Your help is much appreciated!
As far as I understood: you wanted you created so where the problem is?
Example code:
Dim RobApp As RobotApplication
Set RobApp = New RobotApplication
Dim RSelection As RobotSelection Set RSelection = RobApp.Project.Structure.Selections.CreateFull(I_OT_FINITE_ELEMENT) Dim FECol As RobotFiniteElementCollection Dim Collection As RobotNumbersCollection Set FECol = RobApp.Project.Structure.FiniteElems.GetMany(RSelection) Dim OD As RobotObjObject Dim PT As String Dim RT As String Dim CM As String For i = 1 To FECol.Count Set OD = RobApp.Project.Structure.Objects.Get(FECol.Get(i).ObjectNumber) PT = OD.GetLabelName(I_LT_PANEL_THICKNESS) RT = OD.GetLabelName(I_LT_PANEL_REINFORCEMENT) CM = OD.GetLabelName(I_LT_PANEL_CALC_MODEL) Set Collection = RobApp.Project.Structure.Objects.CreateOnFiniteElems(Str(FECol.Get(i).Number), 100000 + i) RobApp.Project.Structure.Objects.Get(Collection.Get(1)).SetLabel I_LT_PANEL_THICKNESS, PT RobApp.Project.Structure.Objects.Get(Collection.Get(1)).SetLabel I_LT_PANEL_REINFORCEMENT, RT RobApp.Project.Structure.Objects.Get(Collection.Get(1)).SetLabel I_LT_PANEL_CALC_MODEL, CM Next i
Can't find what you're looking for? Ask the community or share your knowledge.