question

Li ze avatar image
1 Like"
Li ze asked Marco Baccalaro commented

Problem with forobjecttreeunder and destroyobject

I want to delete networknodes ,but the following code does't work.

forobjecttreeunder(model())
{
	if (comparetext(getnodename(node(">classes/1", a)),"NetworkNode")) 	
	destroyobject(a);
}

FlexSim 16.0.1
destroyobjectforobjecttreeunder
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

Marco Baccalaro avatar image
2 Likes"
Marco Baccalaro answered Marco Baccalaro commented

Use this code:

for (int i = content(model); i > 1; i--)
{
	if (isclasstype(rank(model,i),CLASSTYPE_NETWORKNODE))
		destroyobject(rank(model,i));
}
· 2
5 |100000

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

Li ze avatar image Li ze commented ·

That's right and I got a new command "isclasstype", Thank you very much.

But I want to know why it does't work with "forobjecttreeunder"?

0 Likes 0 ·
Marco Baccalaro avatar image Marco Baccalaro Li ze commented ·

Because while it is searching into the tree you destroy an object and it doesn't work anymore. So, using it, you destroy only the first network node found.

0 Likes 0 ·