Node to Node attr links pass str instead of python objects #181
Replies: 2 comments 6 replies
-
Hey @chrisdreid, great question! In any case I can offer you this workaround: print(' Node2: Type:[%s] *%s*'%(type(self.obj_distal),self.obj_distal)) workaround print(' Node2: Type:[%s] *%s*'%(type(${/node.obj_container}),${/node.obj_container})) Basically if you resolve the token in the code block it should return the real object. This assumes the token is pointing to a node that has already been executed. Hopefully this is helpful to you. We'll continue to talk about this internally. |
Beta Was this translation helpful? Give feedback.
-
Wanted to jump in and talk design for a second, I hope I can contextualize why resolve behaves like it does, and how to build with it in mind. Built in python types tend to have "perfect Nxt's substitution is built to be able to resolve into something that gives users a better since of intent when changing inputs to a script, to show them ahead of time how their value will be used, because we "resolve" that into a string before each node's execution, we need each object to be represented as a string. When you need to pass a rich python object, the If you wanted to build a library to have it's objects substituted freely in nxt, you can implement
This will substitute a creation of a new python object, "Perfectly" the same as the original, into the script when the object is encountered as an attribute value during runtime substitution. Attached is a demo graph using this technique. n.b. that it's best for you to define or import this class in your world node, so that each node has access should it be resolved into it. |
Beta Was this translation helpful? Give feedback.
-
I am having an issue where the piped value of a node attr to another node attr gets represented as a string.
I am using Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) on Windows10
I mocked up a simple example and would like to understand how I can access the object from node->node2 without using global layer value.
pass_str_issue_01.zip
In this example, data is flowing from a layer variable through the piped node attributes:
Layer.simple_obj -> node.obj_container -> node2.obj_distal
This is the output in console:
Thanks,
Chris
Beta Was this translation helpful? Give feedback.
All reactions