Search and replace node names through Python

Search and replace node names through Python

Anonymous
Not applicable
5,007 Views
2 Replies
Message 1 of 3

Search and replace node names through Python

Anonymous
Not applicable

Hi there,

 

I'm wondering if it's possible to do a "search and replace" function in python, to rename all the nodes in my scene.

 

My files comes from maya, and maya don't like nodes wich begins with a number...

 

Basically, I have a lot of nodes named "a555_444444" and i want a lot of nodes named "555-444444"...

 

Can anyone help me with this function ?

0 Likes
Accepted solutions (1)
5,008 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

Ok...with the search function in scenegraph and a little script it's fine.

 

node = getSelectedNodes()
for i in node:
    name = i.getName()
    name = name.replace("a555_", "555-")
    i.setName(name)

Sorry for the inconvenience...not really awake this morning.

Message 3 of 3

seiferp
Community Manager
Community Manager

nice one Smiley Wink

0 Likes