Cursor constraint possible in Python script?

Hi All,
I’m currently writing a script were you have to select certain points on a mesh object.
These points are later on used to draw curves on the mesh.
I started looking for a way to limit the possible position of the next point based on the distance between this new point and the previous one.
I was wondering if it is possible to write this in a python script?

Thanks,

Tom

@TomS,

this is certainly possible, but comes with some tiny drawbacks. Below is an example python script which uses RhinoCommon methods to ask for the mesh and then asks to pick points constrained on this mesh. Note that the core function:

Rhino.Input.Custom.GetPoint()

does indeed have a SetCursor() method, but this cannot be set dynamically while picking points, it has to be set right before calling the Rhino.Input.Custom.GetPoint(), so it is of no use. My guess is that the cursor is used by Rhino, to be controlled eg. when the user tries to pick a point off the object, to which the point picking is constrained.

But there are more fancy ways to inform the user if picking is allowed, eg. within the maximum_distance which can be set in the example. Below script shows one way how to do this using dynamic display, if the mouse cursor is within maximum_distance, a green line is shown from the last picked point to the current point. If the current mouse point is above this distance, a red line is shown and a cursor tooltip indicates it with some text. Of course you´ll need to handle if the user picked anyway in this case. I’ve added some notes in the script…

GetPointWithinDistance.py (2.4 KB)

c.

Thanks Clement!
this was exactly what i’m looking for
Tom