Community
Bifrost Forum
Welcome to the Bifrost Forum. This is the place for artists using Bifrost to ask and answer questions, browse popular topics, and share knowledge about creating effects procedurally using Bifrost. You can also visit the Bifrost Community on AREA to download an array of ready-to-use graphs, read Bifrost news and updates, and find the latest tutorials.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Renaming a node with Python

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
labbejason
705 Views, 3 Replies

Renaming a node with Python

Hi there,

 

I'm testing out if we can fit Bifrost in certain parts of our pipeline and got into scripting a graph. I did run into a problem when trying to rename a node though. It looks like Bifrost acts like Maya, in the sense that if you try to name a node to something that already has the same name, it will automatically increment the name by 1. This is fine and I'm very used to it in cmds, but in cmds it returns the result, while it looks like Bifrost's cmds.vnnCompound(renameNode) returns nothing at all. This is an issue because if the node I'm trying to rename has a conflict I'll suddenly lose reference to the node!

 

Is there some workaround to get its real name in case of a conflict? Ideally cmds.vnnCompound would also have a name parameter that you can set right off the bat, just like cmds.createNode.

Tags (3)
Labels (1)
3 REPLIES 3
Message 2 of 4
labbejason
in reply to: labbejason

This is the best I have so far, but quite the overkill 🙂

Would love to hear if there's a better solution.

 

node = cmds.vnnCompound(graph, "/", addIONode=True)[0]  # Create node.
graph_nodes = cmds.vnnCompound(graph, "/", listNodes=True)  # List all nodes in graph.
graph_nodes.pop(graph_nodes.index(node))  # Remove new node from the list.
cmds.vnnCompound(graph, "/", renameNode=(a, "NEW"))  # Rename it.
new_graph_nodes = cmds.vnnCompound(graph, "/", listNodes=True)  # Re-list all nodes in graph.
node = next(iter(set(new_graph_nodes).difference(graph_nodes)))  # Re-assign value to the one new node.

 

Message 3 of 4
jonah.friedman
in reply to: labbejason

Hi Jason,

 

That's indeed a known issue and it's logged as BIFROST-1648 so you can look out for it in future release notes.

 

Your solution looks like the kind of workaround I'd suggest except your Python is nicer. (I like that last line, readable and compact). 

Jonah Friedman
Bifrost Product Manager
Message 4 of 4
labbejason
in reply to: jonah.friedman

Gotcha, thanks Jonah, I'll keep on eye out on the release notes for future updates!

Tags (1)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report