question

Ryosuke S avatar image
0 Likes"
Ryosuke S asked Phil BoBo commented

How can I insert 3D Object to the 3D view using FlexScript?

Hello, I would like to insert 3D object such as queue , processors, etc. from the library to the 3D view by FlexScript. How can I do that? I can't seem to find commands such as create or load in the FlexScript reference.

The purpose I want to do this is to automate the insert of the 3D object if the customer has the list of equipment in Excel or csv.

Thank you in advance,

FlexSim 19.0.9
flexscriptflexsim 19.0.9
5 |100000

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

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Phil BoBo commented
· 6
5 |100000

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

Ryosuke S avatar image Ryosuke S commented ·
@Jörg Vogel Thank you! Also thank you for the dragconnection. I also needed that.
0 Likes 0 ·
Patrick Cloutier avatar image Patrick Cloutier commented ·

Hello, When I try to create boxes in this fashion:

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

or with this:

createinstance(library().find("Tools/FlowItemBin/Box"), model());

I get a variable/codenode error. But if I put ?Queue or other objects instead of a flowitem all works fine. Is that normal?

It works if I do it with the ProcessFlow activity "Create Object" but I'd need to do it in code for various reasons.

You can see the problem in the attached 1-line model.

1linemodel.fsm

0 Likes 0 ·
1linemodel.fsm (26.7 KiB)
Joerg Vogel avatar image Joerg Vogel Patrick Cloutier commented ·

@Patrick Cloutier, you find Flow Items never in the library! They are in the Flow Item Bin under the Model treenode in Tools. The create object activity involves a field where you can select directly the Flow Item and you don’t need to set a reference as a pointer.

The reference should be

Model.find("Tools/FlowItemBin/Box/Box")

Maybe you can use the sampler tool in the model tree to get the right reference to the object node of a flow item.

If you need a reference directly in Main then it is:

MAIN:/project/exec/globals/FlowItemBin
Tree Organization
0 Likes 0 ·
Patrick Cloutier avatar image Patrick Cloutier Joerg Vogel commented ·

When I use the sampler either in the Toolbox or the Tree I get this:

Model.find("Tools/FlowItemBin/Box")

without the 2nd /Box

and it creates an invisible box with no dimensions and returns this error:

time: 0.000000 exception: int ByteBlock::write(char *source, long unsigned int size, int nullterminate)
ex: write

The only way to make it right is to manually add the 2nd /Box and then it works.

Not very user friendly...

0 Likes 0 ·
Show more comments
Allister Wilson avatar image
2 Likes"
Allister Wilson answered Ryosuke S commented

You can use createinstance to instantiate library objects, and createcopy if you want to create copies of an object you have already preconfigured.

createinstance documentation

createcopy documentation

· 1
5 |100000

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

Ryosuke S avatar image Ryosuke S commented ·

@Allister Wilson Thank you for your reply! I also wanted to give best answer to you but Jörg replied just one minute earlier than you did.

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.