31
Substance Designer - Scripting - Re: Getting values of input properties of an sbsar graph returns default values
on: October 31, 2019, 04:23:54 pm
Quote
...but getting values from the graph being referenced by the node (node.getReferencedResource()) is returning the default values instead of the actual values
So in your example you used node.getReferencedResource() which will most likely return a SDSBSCompGraph object.
This is returning an instance of the graph from the source (sbsar). This source does not have the overrides since the overrides belong to the node.
When the node is created it is simply a representation of the last saved state of the graph. Any overrides you apply to the node, belong to the node, not the graph it was created from.
Maybe it's bad wording on my part, so let me try it this way:
- You're working on pkg_a.graph_a and set your parameters (x=1, y=2). These parameters are recognized as default values.
- You reference pkg_a.graph_a into pkg_b.graph_b, it is now known as node_a. (at this point you haven't applied overrides)
- You query these parameters from node_a and you get x=1, y=2. These are your actual values ONLY in pkg_b, inherited from pkg_a.
- You override these parameters in pkg_b.graph_b.node_a to x=10, y=5. These are your actual values ONLY in pkg_b.
- You query these parameters from node_a again, this time you get x=10, y=5. Still actual values in pkg_b.
Quote
- access the sbsar SDNode by parsing the current graph, get the property value for the integer we modified, we get 5.When you query them using node_a.getPropertyValue(), you're getting the correct values because you're querying them from the pkg_b.graph_b.node_a, which is the source of these overrides.
Quote
- access the sbsar SDGraph from the node (being SDNode.getReferencedResrouce()), get the property value for the integer we modified, we get 1.When you query these parameters using node.getReferencedResoruce(), you get x=1, y=2. This is because you're actually querying them from pkg_a.graph_a, instead of pkg_b.graph_b.node_a.
The overrides you applied in pkg_b.graph_b.node_a belong to node_a.
GetReferencedResource() returns the source of your reference (pkg_a.graph_a), which is in a totally different context than the graph you're currently manipulating (pkg_b.graph_b).