question

Jeremy R avatar image
0 Likes"
Jeremy R asked Felix Möhlmann answered

Create object using template in FlexScript

Is it possible to create an object in FlexScript using another object as a template?

Within my model, some objects are created dynamically using createinstance(). I was hoping to be able to set up an object template, so that whenever I create an object, it is considered an instance of that template.

I tried passing the template object as the class to createinstance(), which did create a copy of that object, but the object is not recognised as an instance of the template. Is there a way to dynamically create instances of object templates?

FlexSim 21.2.3
createinstanceobject template
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

Felix Möhlmann avatar image
2 Likes"
Felix Möhlmann answered

I found this command by exploring the tree of the template entry that gets added to the library when you mark an object as a global template.

applicationcommand("maketemplateinstance", templateObj, ontoObject, Vec3(x, y, z));

The following would create an instance of the template object "Queue1" at the origin point of the model.

applicationcommand("maketemplateinstance", Model.find("Queue1"), model(), Vec3(0, 0, 0));

template_test.fsm


template-test.fsm (25.7 KiB)
5 |100000

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