question

jyothi N avatar image
0 Likes"
jyothi N asked jyothi N commented

network nodes connection by using global table

network-nodes.fsm

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.

FlexSim 18.2.3
network nodestravel networksa connection
network-nodes.fsm (22.9 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Joshua S avatar image
1 Like"
Joshua S answered jyothi N commented

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.

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

jyothi N avatar image jyothi N commented ·

Thank you

0 Likes 0 ·