Which event is triggered when zooming?

I found this method: https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Display_RhinoViewport_GetWorldToScreenScale.htm

I wonder which event is triggered upon the change of its value?

One way is to create a display conduit and override Rhino.Display.DisplayConduit.CalculateBoundingBox, as this will be called when zooming.

– Dale


Hi @dale,

CalculateBoundingBox seems to be firing not only during zoom but also pan. Is there a way to isolate and trigger only if zooming?

Sorry, no.

– Dale

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
            print "zoom event listener stopped."
        callback = dc()
        callback.Enabled = True
        sc.sticky['ZoomCallback'] = callback
        print "zoom event listener started."


Can you think of any workaround, @dale?

Oh, now I see pt is not defined.

Heeyy :slight_smile: I got it.