I wanted to GetWorldToScreenScale within the event handler but Rhino crashes.
This is what I do:
If you uncomment either of the commented lines rhino will crash.
import scriptcontext as sc
import Rhino
vp = None
class dc(Rhino.Display.DisplayConduit):
def CalculateBoundingBox(self,e):
global vp
vp = e.Viewport#.GetWorldToScreenScale(pt)[1]
print vp#.GetWorldToScreenScale(pt)[1]
def zoom_event_helper_func():
#Event trigger helper function
if sc.sticky.has_key('ZoomCallback'):
callback = sc.sticky['ZoomCallback']
if callback:
callback.Enabled = False
callback = None
sc.sticky.Remove('ZoomCallback')
print "zoom event listener stopped."
else:
callback = dc()
callback.Enabled = True
sc.sticky['ZoomCallback'] = callback
print "zoom event listener started."
zoom_event_helper_func()
Can you think of any workaround, @dale?
Update:
Oh, now I see pt is not defined.