Select object by shader and override it with Operator

Select object by shader and override it with Operator

edenexposito
Enthusiast Enthusiast
688 Views
3 Replies
Message 1 of 4

Select object by shader and override it with Operator

edenexposito
Enthusiast
Enthusiast

Hello!

I have 3 Arnold Shaders called : red, green, blue.

I'm testing operators and trying to find any object with "blue" shader applied and replace with a "green" shader. But not seems works, maybe I don't write correctly expression:


*.(shader == "blue")


I attach a screenshot.

5096-arnold-operator-network-editor.jpg

What I'm doing wrong here?


Maybe with something like that in selection:


/*.(@node == 'polymesh' and shader == 'blue|standard_surface')


But no luck.


Thanks!

0 Likes
Accepted solutions (1)
689 Views
3 Replies
Replies (3)
Message 2 of 4

Stephen.Blair
Community Manager
Community Manager

You have to test a parameter value.

*.(@node == 'polymesh' and shader.name == 'Red')

polymesh.shader is a link to a shader node

and

a shader node has a name parameter



// Stephen Blair
// Arnold Renderer Support
0 Likes
Message 3 of 4

peter.horvath6V6K3
Advisor
Advisor
Accepted solution

Exactly what Stephen said. Also note that the name of an Arnold shader exported from C4D has the following format:

/[material_name]|[shader_name]

Spaces and other special characters are replaced with '_'.

So assuming you have an Arnold Material named 'blue' with a standard_surface shader as the root using the default name 'standard_surface' you have to write:

*.(@node == 'polymesh' and shader.name == '/blue|standard_surface')
0 Likes
Message 4 of 4

edenexposito
Enthusiast
Enthusiast

Works like a charm! thank you again!

0 Likes