question

Diego VG avatar image
0 Likes"
Diego VG asked Diego VG commented

Copy/paste subnode by using flexscript

Good morning,

I was wondering if it is possible to copy/paste or duplicate a subnode through Flexscript.

What I intend here is to copy the entire subnode "B0F3_Grid" to the last empty subnode I have added to "grids" in the same way I would do by using copy/paste. I have searched through the doc but I have not found the way to do it through Flexscript.


Thank you very much for your help in advance.

Diego

FlexSim 21.0.0
flexsim 21.0.0treenodeduplicatesubnode
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

Jason Lightfoot avatar image
1 Like"
Jason Lightfoot answered Diego VG commented

The syntax for a part of the tree would be something like this.

  1. treenode origGrid=Model.find("AStarNavigator>variables/grids/B0F3"); // the node you want to copy
  2. nodeinsertafter(origGrid);   //add a new node to replace
  3. createcopy(origGrid,origGrid.next,0,0,0,1); // last parameter is 'replace the node'
  4. origGrid.next.name="CopiedB0F3"; //set the name of the new node

But I think there's more to copying a grid (checking).

· 3
5 |100000

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