Hi there,
I created a new graph, dragged a poly sphere's shape, and connected it to a new build_array node.
I'm struggling to figure out how I can query any kind of data from the build_array node using Python. To be specific, let's say I want to find out the length of the build_array.
I tried out this:
cmds.vnnNode("bifrostGraph1", "/build_array", queryPortDefaultValues="array")
# Error: RuntimeError: file <string> line 2: A port named array was not found on build_array #
Which surprised me, because yes, array is a port and it looks like it's the right internal name.
I also tried this:
cmds.vnnNode("bifrostGraph1", "/build_array", queryPortMetaDataValue=("array", "size"))
# Result: u'' #
Which returns an empty string. I know `size` exists, because I can see it in a watchpoint.
So how in the world can I query this? Am I approaching it the wrong way?
Thanks in advanced!
Solved! Go to Solution.
Solved by jonah.friedman. Go to Solution.
I tried a couple things myself and was unsuccessful so I asked a dev familiar with the commands and he informed me that we can currently only set and get values from input ports. So perhaps there is some room for improvement here. I will look at drawing up an improvement request to explore such future functionality. Dev said a future improvement could be possible to query the watchpoint value from mel/python.
Currently the only way to get the values is to use a Watchpoint inside the graph.
Hi @syracoj thanks for the reply!
I did manage to get the value using the following:
cmds.vnnWatchPoint("bifrostGraph1", "/output", "array", queryRecordedValues="size")
Though it's a bit counter intuitive to achieve this as the output needs to already be connected just to make a new watchpoint. And you need to query the value from the output node, not the build_array (feels kind of weird, rather query directly from the build_array). Now that the watchpoint is no longer needed I must remove it to clean up.
There's also a major issue, and that is it throws an error if you try to create a watchpoint then read the value right after:
cmds.vnnWatchPoint("bifrostGraph1", "/output", "array", create=True)
cmds.vnnWatchPoint("bifrostGraph1", "/output", "array", queryRecordedValues="size") # Errors here if both commands are executed.
But running both commands separately works as expected. So right now it seems like it's impossible to do this purely through script.
Hi Jason,
The reason this isn't easily possible is because the Bifrost graph is a compiled graph - the graph with the nodes you see is kind of like C++ source code, and the only way to get the result from a node is to compile the code and run it. Watchpoints are kind of passive observers of the data flowing by - so they store some information about it, including array size among other things. (And adding a watchpoint does trigger a recompile).
As such, my recommendation would be to use regular data flow to get the values. You can programatically add a "array_size" node inside the graph, expose the result to Maya, and then use Maya's getAttr command. This will cause the graph to compile and run.
Thanks so much for the explanation! Exposing the value to be grabbed from Maya's end sounds like it should work ok. A little more extra overhead to setup and clean up afterwards, but that should be fine 🙂
Hi Jonah!
Have there been any implementations or ways to get this data over the last couple years?
We are currently needing to find any bifrost graphs that are outputing specific data and hide them, or else Arnold will give warnings.
For example, if you have a
render_archive_instance
node connected to the graph's output node, and then click on render, it will error with this:
initializing 9 nodes ...
[bifrost] /bifrostGraph1/bifrostGraphShape1: input0_0_0_graph_outputs_0 object type is unknown
creating root object list ...
Which can cause Arnold to time out, effectively failing the render.
Hi Shane,
It definitely shouldn't fail the render. What versions of Arnold (MtoA), Maya and Bifrost are you using?
Maya: 2019.3.1
Bifrost: 2.3.0.1
Arnold Core: 6.1.0.1
We have had some strange issues with errors and Arnold when it comes to instancing and certain parameters or things aren't done correctly. This may be a user error more than the warning being thrown.
Either way, being able to check if an output port that is of type `bifData` even contains any data or not, would be very helpful.
Can't find what you're looking for? Ask the community or share your knowledge.