Create object using template in FlexScript

Create object using template in FlexScript

jeremy_r
Not applicable
570 Views
1 Reply
Message 1 of 2

Create object using template in FlexScript

jeremy_r
Not applicable

[ FlexSim 21.2.3 ]

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?

0 Likes
Accepted solutions (1)
571 Views
1 Reply
Reply (1)
Message 2 of 2

FelixMoehlmann
Mentor
Mentor
Accepted solution

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