question

Andrew McNitt avatar image
0 Likes"
Andrew McNitt asked Matthew Gillespie answered

Creating instances of objects in model tree with flexscript

Is there a way to create an instance of an object that doesn't exist yet in a new model, using custom script? For example, using the createinstance() command to create a global table when the folder path in the maintree doesn't contain information for global tables yet.

Example:

newtable = createinstance(library().find("?GlobalTable"),model().find("/Tools/GlobalTables"));


This command doesn't work because it can't find "/Tools/GlobalTables" because it doesn't exist until you manually add at least one global table.

FlexSim 22.2.0
createinstance
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

Matthew Gillespie avatar image
1 Like"
Matthew Gillespie answered

To create tool objects programmatically use Tools.create()

Table blankTable = Tools.create("GlobalTable");

To create objects in the model programmatically use Object.create()

Object processor = Object.create("Processor");
5 |100000

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