question

Rohan V3 avatar image
0 Likes"
Rohan V3 asked Jason Lightfoot commented

Duplicate Global Table using Flexscript

I am building a user library which has some in built tables. The tables auto-load as the user imports the library into the model. I have an object with a dropscript and I am trying to duplicate the library global tables in the model with different names when the user drops that object onto the 3D model. I want to be able to duplicate the tables (instead of creating new ones) so that all the on reset code gets copied to the new tables.


FlexSim 23.2.2
global tableuser commandapi
· 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.

Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·

This sounds like the labels could be stored as tables on the objects - something to consider.

0 Likes 0 ·

1 Answer

·
Kavika F avatar image
1 Like"
Kavika F answered Rohan V3 commented

Hey @Rohan V3, you can use Flexscript to copy the Global Table's node in the tree. This will copy over all variables, including the On Reset trigger code.

string path = "Tools/GlobalTables/GlobalTable1";
treenode gt = Model.find(path);
treenode copy = gt.copy();
copy.name = "newTable";

You can replace the "path" variable with the path to your global table. This code will find the node and copy it. You can then rename.

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

Rohan V3 avatar image Rohan V3 commented ·
Haha thanks! Pretty simple :)
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.