question

Patrick Zweekhorst avatar image
2 Likes"
Patrick Zweekhorst asked Patrick Zweekhorst commented

Different result when running code in debug or not

Hi,

I have created a small example model which shows my problem in a larger model. The code makes a copy of two conveyors and creates an A-connection between them. There are 3 possible ways to run the code, of which only one seems to work:

1) Just run the scrip by pressing the green run button. The conveyors are created, but the connection is not. If you press the new top right conveyor you will get all kinds of error messages. It is also not possible to delete the conveyor anymore. So this conveyor seems to be broken pretty bad.

2) Run the code in debug mode, but just press run in the debug window. This results in the same thing as point 1.

3) Run the code in debug mode and step through the code line by line. This results in the correct results. The conveyors are created and the connection as well.

What might cause this difference?
Is there a work around for this? Should I call some other functions on the conveyor? Or what is going wrong here?

For reference the code I use:

  1. Object con1 = Model.find("Conveyor1");
  2. Object con2 = Model.find("Conveyor2");
  3. Object newCon1 = createcopy( con1, model() );
  4. Object newCon2 = createcopy( con2, model() );
  5. newCon1.location.y = 5;newCon2.location.y = 5;
  6. contextdragconnection( newCon1, newCon2, "A" );

If something is not clear please let me know.
Thanks for the help,

Patrick

ConveyorConnections.fsm

FlexSim 20.1.2
flexsim 20.1.2connectionsdebugconveyor module
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

anthony.johnson avatar image
3 Likes"
anthony.johnson answered Patrick Zweekhorst commented

Haven't opened your model yet, but my initial impression is that you need to call firecreateevent() on the objects that you create. createcopy() unfortunately doesn't call this automatically. They need their OnCreate to fire so they can connect themselves to the conveyor system.

· 3
5 |100000

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