question

George C2 avatar image
0 Likes"
George C2 asked Matthew Gillespie edited

Code: How to set a conveyor type to "Custom"?

Background: I have created a curved conveyor through custom code in a process flow:

newConveyor = createinstance(node("conveyor/CurvedConveyor", library()), model());

Goal: I want to convert this "newConveyor" into a conveyor with a "Custom" type using FlexSim Code.

Reason: I am doing this mainly to try and get around this one issue that throws an error; if I use the createcopy(__) command instead of createinstance(__) for conveyor, I get this error:

time: 2.032000 exception: Exception caught in TreeNode::receivemessage()
time: 2.032000 exception: EditorSpatial::prepareDraw()
time: 2.192000 exception: Exception Caught in ObjectFunction251__project_library_FlexSimObject_behaviour_eventfunctions_OnPreDraw object: /
FlexSim 19.1.0
conveyorcodecustom codecustomtype
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

·
Matthew Gillespie avatar image
1 Like"
Matthew Gillespie answered Matthew Gillespie edited

A custom type conveyor has its type variable pointing at its own localType variable.

Object conveyor = createinstance(node("conveyor/CurvedConveyor", library()), model());
getvarnode(conveyor, "type").value = getvarnode(conveyor, "localType");

If you want to make the conveyor custom type but keep all the settings of its previous type (they're the same in your case, but someone else might want to do this) you need to copy the previous type into the conveyor's localType variable.

Object conveyor = createinstance(node("conveyor/CurvedConveyor", library()), model());
treenode curType = getvarnode(conveyor, "type").value;
createcopy(curType, getvarnode(conveyor, "localType"), 0, 0, 0, 1).name = "localType";
getvarnode(conveyor, "type").value = getvarnode(conveyor, "localType");
5 |100000

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

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.