Using SetPt to move grips in python script

I’m having some trouble getting this python script to work. In brief, in want to be able to select a subset of grip points from a mesh object, and move them all so their z coordinate = 0 (either manually or automatically). I’ve tried a number of variations but can’t seem to get the right way to give the selected grips to the _SetPt command. Any ideas? Thanks in advance.

import rhinoscriptsyntax as rs

# Select grips
grips = rs.GetObjects("Choose points to move", filter=16384)

# Edit selected points
setpts = ("-_SetPt " + "selid " + str(grips) + "_Enter " + " _XSet=_No _Enter " +
   " YSet=_No _Enter " + " ZSet=_Yes _Enter" + " Alignment=_World _ Enter ")
rs.Command(setpts)

Hi Scott,

Grips need special treatment when selecting via scripting.

The most siple solution is to let rs.GetObjects select the objects picked.
next you can run the command without the need of an additional selection procedure:


# Select grips
grips = rs.GetObjects("Choose points to move", filter=16384, select=True)

# Edit selected points
setpts = ("-_SetPt XSet=_No YSet=_No ZSet=_Yes Alignment=_World w0 ")
rs.Command(setpts)

If you are planning to do more elaborate scripting on grips have a look at the methods

http://4.rhino3d.com/5/ironpython/index.html#modules/object_grip_module.htm

HTH
-Willem

1 Like

Excellent, just the kind of simple solution that I was looking for. Thanks!