question

Lucas Klein avatar image
3 Likes"
Lucas Klein asked Phil BoBo edited

Module SDK - Object detection, snap function

Hello,

I am trying to create a new object that uses some functions that already exist in the Decision Point and Control Point, such as:

  • identifying a nearby object and snap to it
  • draw not-resizable shapes (I noticed that both Decision and Control Points have the same shape and drag behavior while setting them at the model)
  • listen to passing objects without having flow connections (OnArrival / OnReceive)

Are there any commands or codes that allow me to apply those functions in my object?

I am using the Module SDK to create this new object in FlexSim, and I was trying to use the "checkCollision()" method, but had no success using the function. My object currently extends the FlexsimObject class

FlexSim 20.0.3
conveyordecision pointsmodule sdkdevelopmentcontrol points
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

·
Phil BoBo avatar image
1 Like"
Phil BoBo answered Phil BoBo edited

1. The Control Point and Decision Point classes each implement the onDrag() method in order to fire code when being moved. That custom onDrag() code loops through the interesting objects in the model (conveyors for decision points and agv paths for control points) to determine whether to set the objects position to "snap" to those objects. This is all custom code, and you would also need to write custom code to get this type of behavior. You can use the draginfo() command in the onDrag() method to get information about the mouse drag operation.

2. You can hide the sizer cones by calling setpickingdrawfocus() from the onDraw() method of your object, using the OVERRIDE_DRAW_ALL option to "cause FlexSim to not draw any sizers or boxes around the object."

You can use the Mesh API to draw whatever you want. See mesh.h in the Module SDK. The Module SDK Documentation "ExampleModuleClass.html" Snow Processor tutorial shows an example of using the Mesh class from a module. You can also find FlexScript examples of using the Mesh API here on Answers, such as:

How to use mesh API?

How do I add a texture to a mesh when using the mesh API

The principles of using the Mesh API are the same between C++ and FlexScript, but the syntax is slightly different.

3. Those events are generated by the AGV Network and Conveyor System objects respectively for Control Points and Decision Points. The code controlling what is happening when an item is on a conveyor or using the AGV network is written on those objects, so they use that data to fire events at particular times (related to the positioning of those objects). This is what you have to code up in order to "create a new object." You have to tell it when to fire triggers that are important relative to your object and its logic.

The checkCollision() method is related to the Collision tab on task executer objects. Almost no one uses that feature. It is an old, slow, ticker-based system that is almost never used because there is almost always a better, more efficient way to calculate important events instead of doing collision detection every X time units.

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.