- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I started programming C# RSA , I have difficulties to translate code from vb to c#. Please help me .
please write sample code
how to change:
1) tools / job preferences / materials / basic set / steel
how to change type of steel for example: put S355
RobotMaterialData Material;
2) how to
create a new section
standard
Database: Simple Catpro Family: HEA Section: HEA120 Section type Aluminum
3) on the http://www.robobat.com/n/ros/
There is a code In vb , I couldn’t translate all to c#, please correct me
It is original code:
Reading the basic geometry
Declare the main variable representing the Robot application and connect it to the currently running instance of Robot.
Dim robapp As IRobotApplication
Set robapp = New RobotApplication
Get the collection of all bars from the structure.
Set bar_col = robapp.Project.Structure.Bars.GetAll()
Iterate for consecutive bars from the collection.
For i = 1 To bar_col.Count
Get the object representing the following (i-th) bar in the collection.
Set bar = bar_col.Get(i)
Read required attributes of the i-th bar.
bar_num = bar.Number
start_node_num = bar.StartNode
end_node_num = bar.EndNode
Declare variables defining individual nodes.
Dim start_node As IRobotNode, end_node As IRobotNode
Get the node with start_node_num number from the server.
Set start_node = robapp.Project.Structure.Nodes.Get(start_node_num)
Read the values of coordinates x, y, z for the node with start_node_num number.
start_node_x = start_node.X
start_node_y = start_node.Y
start_node_z = start_node.Z
Get the node with end_node_num from the server and read its coordinates.
Set end_node = robapp.Project.Structure.Nodes.Get(end_node_num)
end_node_x = end_node.X
end_node_y = end_node.Y
end_node_z = end_node.Z
Free all declared variable references.
Set bar = Nothing
Set start_node = Nothing
Set end_node = Nothing
Repeat the operation of reading data for the next bar from the collection.
Next
Free all the references declared in the example.
Set bar_col = Nothing
Set robapp = Nothing
!!!!!!!!!!!!!!!!!!!!!!!!
Mine code:
IRobotApplication robApp;
robApp = new RobotApplicationClass();
IRobotCollection bar_col = robApp.Project.Structure.Bars.GetAll();
for (int i = 0; i <= Convert.ToInt32(bar_col.Count); i++)
{
// IRobotBar bar = bar_col.Get(i);
// this below is something wrong
IRobotBar bar = robApp.Project.Structure.Bars.Get(i);
}
Error 1 Cannot implicitly convert type 'RobotOM.IRobotDataObject' to 'RobotOM.IRobotBar'. An explicit conversion exists (are you missing a cast?) G:\nauka c# cad\Robot02\Robot02\Form1.cs
4) Remove selected load cases
Declare the main variable representing Robot aplication and its connection to the currently running program instance.
Dim robapp As IRobotApplication
Set robapp = New RobotApplication
Dim casesrv As IRobotCaseServer
Set casesrv = robapp.Project.Structure.Cases
Get the collection including all load cases.
Dim casecol As IRobotCaseCollection
Set casecol = robapp.Project.Structure.Cases.GetAll()
Iterate for consecutive cases from the collection.
For i = 1 To casecol.Count
Get i-th case
Dim c As IRobotCase
Set c = casecol.Get(i)
Remove the case from the server if the analysis type is different from the linear static analysis.
If c.AnalizeType <> I_CAT_STATIC_LINEAR Then casesrv.Delete c.Number
Free variable representing a case
Set c = Nothing
Repeat the iteration for the following case.
Next
Mine code:
IRobotApplication robApp;
robApp = new RobotApplicationClass();
IRobotCaseServer casesrv;
casesrv = robApp.Project.Structure.Cases;
IRobotCaseCollection casecol;
casecol = robApp.Project.Structure.Cases.GetAll();
for (int i = 0; i <= Convert.ToInt32(casecol.Count); i++)
{
IRobotCase c;
c = Convert.ToInt32(casecol.Get(i));
if (c.AnalizeType != IRobotCaseAnalizeType.I_CAT_STATIC_LINEAR)
// this below is something wrong
casesrv.Delete(c);
}
5)
IRobotStructure str;
str = robApp.Project.Structure;
// Generate new load case.
IRobotSimpleCase caseExp;
caseExp = robApp.Project.Structure.Cases.CreateSimple(str.Cases.FreeNumber, "caseExp",
IRobotCaseNature.I_CN_EXPLOATATION, IRobotCaseAnalizeType.I_CAT_STATIC_LINEAR);
// Define load record types.
caseExp.Records.New(IRobotLoadRecordType.I_LRT_NODE_FORCE);
IRobotLoadRecord LoadRecord; // rec
LoadRecord = (RobotLoadRecord)caseExp.Records.Get(1);
// this below is something wrong
LoadRecord.SetValue(IRobotBarUniformRecordValues.I_BURV_LOCAL, true);
6)
IRobotViewDisplayParams ParamsDisplay01;
ParamsDisplay01 = ? (how to declare )
ParamsDisplay01.Set(IRobotViewDisplayAttributes.I_VDA_STRUCTURE_NODE_NUMBERS, true);
Solved! Go to Solution.
