question

Martin K5 avatar image
0 Likes"
Martin K5 asked Martin K5 commented

How do I create plane by code?

Hi,

I would like to ask, how do I create a plane by code? I would like to create this plane before I am creating the whole model and be able to move it to this plane.

Thank you.

Martin

FlexSim 21.1.4
codeplanemoveobject
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

·
Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Martin K5 commented

createinstance

you can assign the created plane directly to a declared treenode variable and move objects into it or create other objects in this reference.

using Containers

· 4
5 |100000

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

Martin K5 avatar image Martin K5 commented ·

Hi,

thanks for you answer, I would go with the way of creating the instance, I tried, but an error occurs. I am using this line of code:

Object plane = createinstance(library().find("?Plane"), model()); 

Do you know where the mistake is?

Thank you

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Martin K5 commented ·

That code is looking for a node called "Plane" under the library() node. There is no node called "Plane" under the library() node.

1633700067327.png

The Plane object shown in the Library view is an instance of the VisualTool class.

You could create an instance of that class directly:

createinstance(library().find("?VisualTool"), model());

or you could create a copy of a pre-configured instance (which is what happens when you drag in an object from the Visual section of the Library view):

createcopy(node("MAIN:/project/exec/globals/visuallibrary/Plane"), model());
1 Like 1 ·
1633700067327.png (31.6 KiB)
Martin K5 avatar image Martin K5 Phil BoBo ♦♦ commented ·
Thanks a lot.
0 Likes 0 ·
Martin K5 avatar image Martin K5 commented ·
The problem occurs when I create the plane manually and then place the whole model on the container and I am trying to assign it together and then the model is de-centered, but its location are set up in the code and I do not want to re-locate them by hand.


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.