Copy/paste subnode by using flexscript

Copy/paste subnode by using flexscript

diego_vg
Not applicable
35 Views
4 Replies
Message 1 of 5

Copy/paste subnode by using flexscript

diego_vg
Not applicable

[ FlexSim 21.0.0 ]

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.

35600-capture-decran-2020-12-23-113637.png


Thank you very much for your help in advance.

Diego

0 Likes
Accepted solutions (1)
36 Views
4 Replies
Replies (4)
Message 2 of 5

jason_lightfootVL7B4
Autodesk
Autodesk
Accepted solution

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).

Message 3 of 5

diego_vg
Not applicable

Thanks a lot!

0 Likes
Message 4 of 5

jason_lightfootVL7B4
Autodesk
Autodesk

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);


Message 5 of 5

diego_vg
Not applicable

I will give it a try. Thanks again

0 Likes