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.

treenode origGrid=Model.find("AStarNavigator>variables/grids/B0F3");  // the node you want to copy
nodeinsertafter(origGrid);       //add a new node to replace
createcopy(origGrid,origGrid.next,0,0,0,1); // last parameter is 'replace the node'
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.

Diego VG avatar image Diego VG commented ·

Thanks a lot!

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Diego VG commented ·

Yes - I don't think coping the grid nodes is good - I seemed to get predraw errors.

You might have better luck using function_s but as these are not officially supported they may not function in the future.

Object astarnav=Model.find("AStarNavigator");
treenode createdgrid= function_s(astarnav, "createGrid", 0, 0, 0);
setsdtvalue(createdgrid,"minPointX",-5);
setsdtvalue(createdgrid,"maxPointX",5);
setsdtvalue(createdgrid,"minPointY",-5);
setsdtvalue(createdgrid,"maxPointY",5);


2 Likes 2 ·
Diego VG avatar image Diego VG Jason Lightfoot ♦ commented ·

I will give it a try. Thanks again

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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