You can 'monkeypatch' nuke: nuke.MY_CLASS = classInstance
micah ----- Original Message ----- From: "Christopher Horvath" <[email protected]> To: "Nuke Python discussion" <[email protected]> Sent: Thursday, January 26, 2012 10:40:37 AM Subject: Re: [Nuke-python] Storing blind user data on nodes with Python I don't actually need the object to persist across sessions - just within a single session, so that each time Nuke edits the node, the same class instance exists. If I have to recreate it each time, it just means that I'm re-opening a file and interpreting its contents over and over in response to a mouse click, which is slow. Chris On Thu, Jan 26, 2012 at 10:33 AM, Nathan Rusch < [email protected] > wrote: The only way to do this between Nuke sessions would be to serialize the Python object somehow and store it in a text knob on the node. The Node.metadata() method is returning a copy of the node’s metadata in the form of a dictionary (presumably assembled from the underlying DDImage::MetaData::Bundle object every time the method is called). The dictionary object is not actually directly associated with the node, and is in no way stored with the node itself. -Nathan From: Christopher Horvath Sent: Thursday, January 26, 2012 10:18 AM To: Nuke Python discussion Subject: [Nuke-python] Storing blind user data on nodes with Python Hello Again, Nuke! Is there a way to create an instance of a Python object and have it be persistently stored with a node instance? I was thinking I could just add the instance to the node's metadata, which seems to be just a python dictionary, and therefore capable of storing any Python object. However, I wasn't sure if the dictionary was created on the fly as a mirror of some internal, non-pythonic representation. Also, metadata seems to be copied from one node to the next, which could be confusing with respect to this unusual usage of it. I have a python class (which, sadly, I don't have a C++ version of ) which carries some moderately expensive state with it that I need to use to compute parameter data for the node. I'd like to be able to create an instance of this class and stick it onto the node (like UserData on Widgets in Xt). Can I do this? Chris -- I think this situation absolutely requires that a really futile and stupid gesture be done on somebody's part. And we're just the guys to do it. _______________________________________________ Nuke-python mailing list [email protected] , http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python _______________________________________________ Nuke-python mailing list [email protected] , http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python -- I think this situation absolutely requires that a really futile and stupid gesture be done on somebody's part. And we're just the guys to do it. _______________________________________________ Nuke-python mailing list [email protected], http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________ Nuke-python mailing list [email protected], http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
