Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

Issue: EventListener callback is not executed in ScriptEditor

$
0
0

Hi there,

i am experiencing issues with Events in combination with the scriptEditor

I have used the mechanism below to listen to view change events. When I execute the code in the old editor (editPythonScript / runPythonscript ), my events trigger the callback as expected
image

however when I execute the same script in the scriptEditor, the callback is not triggered. The same issue occors for at least the folllowing:

  • Rhino.RhinoDoc.CloseDocument
  • Rhino.RhinoDoc.BeginOpenDocument
  • Rhino.RhinoDoc.EndOpenDocument
  • Rhino.RhinoDoc.InstanceDefinitionTableEvent

hopefully someone can help me out

Thanks,
Tim

import Rhino
import scriptcontext as sc

def callback(sender, e):
    print('view has changed')

if __name__ == '__main__':
    event = Rhino.Display.RhinoView.SetActive
    key = 'AutoLockSheetListener'
    if sc.sticky.has_key(key):
        func = sc.sticky[key]
        event -= func

        del sc.sticky[key]
        print("%s: remove callback" % key)

    else:
        func = callback
        event += func
        sc.sticky[key] = func
        print("%s: add callback" % key)

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles