Python Node accessing Python Object

   2237   3   0
User Avatar
Member
643 posts
Joined: June 2006
Offline
how can i pass a python object from one node to another:

Example:

python_C want's to get a python object from each node python_A and python_B. whats the best way?

Attachments:
python_nodes.png (11.4 KB)

User Avatar
Member
459 posts
Joined: Oct. 2011
Offline
Hi
I'm not sure you can pass programatic objects from node to node like that. Correct me if i'm wrong though. Can't you put all your code in one Python node?

-b
http://www.racecar.no [www.racecar.no]
User Avatar
Member
28 posts
Joined: Jan. 2010
Offline
You don't have access to each node's code, so the code itself would have to store python objects in the node's user data.

You can specify strings in userData, or objects in cachedUserData. So you could have the following in nodeA

class Foo(object):
pass

node.setCachedUserData('foo', Foo())
node.setUserData('bar', ‘baz’)

and then access it in nodeC with the following:

nodeA = node.inputs()
foo = nodeA.cachedUserData('foo')
bar = nodeA.userData('bar')

Keep in mind that userData is volatile, it gets deleted once the scene is closed. cachedUserData is stored in the file itself, and thus never deleted.
Blair Pierpont @ weta digital
User Avatar
Member
643 posts
Joined: June 2006
Offline
sounds good blair_p :-)

thanks for the information.

bonsak
well my target was to play a bit with OCC:http://www.pythonocc.org/ [pythonocc.org]
to use multiple nodes is much simpler then just using one node. :-)

thanks for the wonderful support :-)
  • Quick Links