Create conveyor system in code

Create conveyor system in code

axel_kohonen
Not applicable
26 Views
2 Replies
Message 1 of 3

Create conveyor system in code

axel_kohonen
Not applicable

[ FlexSim 16.0.1 ]

Hi,

I am creating a conveyor system consisting of a straight conveyor with a photo eye and a decision point on it. There are multiple of these conveyors next to each other. I manage to create the conveyors and the photo eyes and decision points, but only the first that is created of the photo eyes/decision points works correctly. For the first I create the photo eye into the conveyor using createinstance and Flexsim moves the photo eye to the same rank level as the conveyor and creates the link between them. For the other ones the objects remain inside the conveyor and thus the rest of the code does not work as it should. Also, when stepping through the code with the debugger so that I put breakpoints on the rows where the decision points, photo eyes and before the connections from and to the conveyor are created then the code works as it should, probably due to some timing issue.

Anyone that has a clue on how to fix this problem? See the attached model where the problem is replicated.

Call the createConveyorSystem user command from the script window as I have defined it there to see what happens.

20160606-buildingconveyorsystemwithcode.fsm

Accepted solutions (1)
27 Views
2 Replies
Replies (2)
Message 2 of 3

Matthew_Gillespie
Autodesk
Autodesk
Accepted solution

After you add a photo eye or a decision point you need to call the finalizeSpatialChanges function on the thing you just added and not on the conveyor. So change these lines:

** Just added a Photo Eye **
function_s(newConveyor,"finalizeSpatialChanges");

** Just added a Decision Point **
function_s(newConveyor,"finalizeSpatialChanges");

To these:

** Just added a Photo Eye **
function_s(photoEye,"finalizeSpatialChanges");

** Just added a Decision Point **
function_s(decisionPoint,"finalizeSpatialChanges");


Matthew Gillespie
FlexSim Software Developer

Message 3 of 3

axel_kohonen
Not applicable
20160606-buildingconveyorsystemwithcode-v2.fsm

Thank you Matthew! So finalizeSpatialChanges obviously always needs to be called for the object that you have made changes to. Weird that it worked to call it for the conveyor though when the breakpoints were set in the spots described above.

The corrected model is attached.

Thanks!

Axel

0 Likes