When I enter an alias with macro for an object snap such as _CenterSnap while
import rhinoscriptsyntax as rs
is waiting for input,
The "Center" point picking option is available only when picking points.
is reported on the command line, and the snap is not enabled.
The same alias works during a Rhino command, e.g. _Point
Is there a way to use an alias for an object snap while running a Python script via _RunPythonScript or from the Rhino Python Editor?
You can use this function to set only center object snap:
old_osnap_state = ModelAidSettings.OsnapModes # store current object snap settings
cen() #set center object snap
# do your getpoint stuff
ModelAidSettings.OsnapModes = old_osnap_state # restore osnap settings
#turn off all Osnaps except center Osnap
cen = Rhino.ApplicationSettings.OsnapModes.Center
Rhino.ApplicationSettings.ModelAidSettings.Osnap = True
Rhino.ApplicationSettings.ModelAidSettings.OsnapModes = cen
if __name__ == "__main__":
Thanks, but I’m looking to use a custom alias to on-the-fly set an object snap while _RunPythonScript is executing a script, waiting for the point input.
In the case of using _CenterSnap, I would like to enter CS when the script is waiting for the point input.
Yeah, this is odd - seems like running snaps from aliases is explicitly excluded while running a script…
If I run
rs.GetPoints() and then try to pick the center point of a circle (while it is not checked in the osnap panel)
- Clicking on the “Center” osnap toolbar button - works
- Typing out the snap at the command line (i.e. CenterSnap) - works
- Typing a pre-set alias for the center snap (i.e. cs=CenterSnap) - fails
with the message “The “Center” point picking option is not usable at this time.”
Hi all - - I see this… no idea if that is fixable but I’ll add to the pile - thanks.
RH-68828 Osnap aliases not available in script