question

VikSin avatar image
1 Like"
VikSin asked Jason Lightfoot edited

createinstance for user library object


Hello, I am trying to run a script that will automatically create an object from my userlibary. I am using an createinstace() command for this. Lib. object is a plane with 3 objects as a subnodes. When i drag and drop this plane_custom_object from the library toolbar, everything workd fine, but when i tried to achieved this with a script, only the plane itself is created, without the other objects.

Script here:

Object object;
for (int i = 1; i <= 3; i++)
{
    object = createinstance(maintree().find("project/userlibrary/test_lib/Plane2"),model());
    object.location.x = 5;
    object.location.y =  -i * (object.size.y + 2);
}

My user library tree:
flx-qst-uselib.pngProblem on picture here:
flx-qst-createinstace.png

How can i modify my script to work properly ?

Thank you for an advice.

FlexSim 23.2.0
flexscriptcreateinstace
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

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

Use createcopy() instead - these are not true library objects that warrant createinsance()

5 |100000

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