I’m using GetPoint to select some 3D widgets I’ve created but can’t seem to find a setting how to override this small crosshair “dot”. I added a red point behind it in my conduit so you can see it in the snip easier:
"""This Class is used during selecting the actual gizmo object"""
class CustomGetPoint(Rhino.Input.Custom.GetPoint):
def __init__(self):
super(CustomGetPoint, self).__init__()
self.translation_mode = None
self.temp_transform = None
# Specific settings
self.PermitOrthoSnap(False)
self.PermitObjectSnap(False)
self.PermitConstraintOptions(False)
self.PermitFromOption(False)
self.EnableSnapToCurves(False)
self.EnableObjectSnapCursors(False)
self.SetCursor(Rhino.UI.CursorStyle.Default)
self.SetCommandPrompt("Click on gizmo element or press ESC")
def OnDynamicDraw(self, e):
# Don't call the base class
pass
For a different instance where I may need to utilize OnDynamicDraw is there a different way to be calling that or would my dynamic draw logic go into the definition still?
def OnDynamicDraw(self, e):
# My custom drawing logic here?
OR
def OnDynamicDraw(self, e):
# Don't call the base class
pass
# MyCustomDynamicDrawingLogic(self, e):
# override somewhere else?
Use the first case: pass means there is an empty implementation on that line, so when you put your custom drawing logic instead of pass it’ll start doing something. The second case does not exist.
Can I add custom drawing logic before pass, then call pass after to ensure that my logic gets drawn but Rhino’s logic does not? Or is it more of using pass to just skip the OnDynamicDraw function entirely?
So in the case of this post above , I get to draw a dot or whatever I want, then add pass after that, and then Rhino will NOT draw anything like the crosshair point?
pass is only a no-op. A valid Python keyword, but it does nothing. This is for instance useful when you need a method implementation, but not doing anything. If you put it inside a method but surrounded by other code then you’ll just have a line that does nothing:
def method_doing_nothing():
pass
def method_doing_nothing_and_more():
pass
print("more than nothing")
Try this in a REPL and call either of the methods and see what happens.
In other words: pass does not mean stop code execution in current scope.
If you want to have the same implementation do two different things based om some state or conditionals you should leave early or write your if-else blocks in such a way.
def do_one_or_other(do_one):
if do_one:
# maybe nothing for one?
return
else:
print("not do_one")
print("Other stuff")
do_one_or_other(False)
do_one_or_other(True)
@nathanletwory Thanks for putting it together in an explanation, it’s a helpful breakdown and mirrors the behavior I have seen and implemented. Cheers!