in my model i want to create network nodes by using coordinates and name taken from the global table and they have to be connected by using A type .i added some script in that model and i was unable to execute it.
in my model i want to create network nodes by using coordinates and name taken from the global table and they have to be connected by using A type .i added some script in that model and i was unable to execute it.
Here's your code that will work now
int numRows = Table("GlobalTable1").numRows; int x_Col = 2; int y_Col = 3; int z_Col = 4; int Name_COL = 1; treenode prevnode = NULL; for (int i=1; i<=Table("GlobalTable1").numRows; i++) { int xLoc=Table("GlobalTable1").cell(i,x_Col).value; int yLoc=Table("GlobalTable1").cell(i,y_Col).value; int zLoc=Table("GlobalTable1").cell(i,z_Col).value; string newName = Table("GlobalTable1").cell(i,Name_COL).value; treenode nnode = createinstance(library.find("?NetworkNode"),model()); nnode.as(Object).location.x=xLoc; nnode.as(Object).location.y=yLoc; nnode.as(Object).location.z=zLoc; nnode.name=newName; if (objectexists(prevnode)) contextdragconnection(prevnode, nnode, "A"); prevnode = nnode; }
If you want to access functions or variable inherent to a specific class, you should use .as(Class), rather then put the class in front unless you are defining a new object. The code above also limits the iterations to the length of your rows in the global table now.
8 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved