Pete O'Connell wrote: > Hi I was wondering if there is a way to disable a function. > Hi have a GUI grid snapping function that I use in a program called Nuke > (the film compositing software) > > Here is the function (which loads when Nuke loads): > ####################### > def theAutoplaceSnap(): > try: > nuke.thisNode().autoplace() > n = nuke.allNodes(); > for i in n: > nuke.autoplaceSnap(i) > except: > pass > > nuke.addOnUserCreate(theAutoplaceSnap) > ################################### > > I have many functions which get loaded, but this particular one needs to > be disabled when I am viewing another compositors script in the gui. > > I have a python script editor in Nuke in which I can run code if need be > to run code on the fly.
http://docs.thefoundry.co.uk/nuke/63/pythondevguide/callbacks.html#onusercreate suggests that you can remove the callback with nuke.removeOnUserCreate(theAutoplaceSnap) You can later add it back with nuke.addOnUserCreate(theAutoplaceSnap) like in the code snippet you provided. If the add/removeOnUserCreate() calls occur in another module than the one theAutplaceSnap() is defined in you need to import that first and use qualified names (e. g. some_module.theAutoplaceSnap). _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
