How do I create plane by code?

How do I create plane by code?

martin_k5
Not applicable
61 Views
5 Replies
Message 1 of 6

How do I create plane by code?

martin_k5
Not applicable

[ FlexSim 21.1.4 ]

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

0 Likes
Accepted solutions (1)
62 Views
5 Replies
Replies (5)
Message 2 of 6

joerg_vogel_HsH
Mentor
Mentor
Accepted solution

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

0 Likes
Message 3 of 6

martin_k5
Not applicable

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
Message 4 of 6

martin_k5
Not applicable
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
Message 5 of 6

philboboADSK
Autodesk
Autodesk

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());


Phil BoBo
Sr. Manager, Software Development
Message 6 of 6

martin_k5
Not applicable
Thanks a lot.
0 Likes