Module Development : Simple Way to Disable Snap to Grid

Module Development : Simple Way to Disable Snap to Grid

jstevensE9YZD
Explorer Explorer
217 Views
4 Replies
Message 1 of 5

Module Development : Simple Way to Disable Snap to Grid

jstevensE9YZD
Explorer
Explorer

Hey,

Is there an easy way to prevent an object from snapping to the grid in C++? Would it be done in onDrag()?

How the conveyor doesn't snap to the grid is what I'm looking for.

Thanks,

0 Likes
Accepted solutions (1)
218 Views
4 Replies
Replies (4)
Message 2 of 5

joerg_vogel_HsH
Mentor
Mentor

If you set a location by script, such an object does not snap to the grid. Only objects you drag into your model are snapping to the grid. Or objects that you move by mouse snaps to the grid. Currently I have not FlexSim opened to look into the tree to find the node myself. It should be an attribute (node) of a view tree of the window you drag objects onto. It is mentioned for example in manual for custom graphical user interface (GUI). You find it in the view tree of FlexSim in active branch. 

0 Likes
Message 3 of 5

jstevensE9YZD
Explorer
Explorer

@joerg_vogel_HsH 

The reason I mentioned onDrag() was that I want to drag a specific object around a view and not have it snap to the grid. I don't want to turn off snap to grid for the rest of the objects.

0 Likes
Message 4 of 5

Matthew_Gillespie
Autodesk
Autodesk
Accepted solution

Yeah, the conveyor objects override onDrag() and return 1 so it doesn't do the normal behavior. Basically you'd add an onDrag() like this to your object:

 

if (!draginfo(DRAG_INFO_BUTTON_STATE)) // mouse wheel
	return 0; // let view zoom

Vec3 diff(draginfo(DRAG_INFO_DX), draginfo(DRAG_INFO_DY), draginfo(DRAG_INFO_DZ));

b_spatialx += diff.x;
b_spatialy += diff.y;
b_spatialz += diff.z;

return 1;


Matthew Gillespie
FlexSim Software Developer

0 Likes
Message 5 of 5

jstevensE9YZD
Explorer
Explorer

Thanks @Matthew_Gillespie !

That was exactly what I was looking for, glad it was so simple.

 

0 Likes