Arnold for Maya Forum
Rendering with Arnold in Maya using the MtoA plug-in.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I use ai user data in operators ?

Message 1 of 7
773 Views, 6 Replies

How can I use ai user data in operators ?

Is it possible to inject user data string for example in a operator ?

I want to assign shaders based on a user data string.

Labels (3)
Message 2 of 7
in reply to: idizdar

EDIT: See Orn's answer. You can use user data values in assignment expressions.

I was thinking about control flow based on user data, sorry.

You want the operator to assign shaders based on user data that is already in the scene?

There's no way to do that.

A set_parameter operator can create user data on shapes. You add a custom assignment, where you specify the string type. Then in the shading tree you could get that user data and do different things based on the value.

// Stephen Blair
// Arnold Renderer Support
Message 3 of 7
in reply to: idizdar

Thanks for your answer,

So if I understand well there is no way that user data can control or override shader assignation ?

I am exporting a forest from Houdini as ass file, But I am doing my rendering in Maya.

I know is possible to separate shaders and shapes in different ass files as long as shapes have the correct assignation.

I wanted to go that way but I failed to generate the assignations only based on attributes.

It doesn't work if Arnold can not find the shaders in Houdini ...

May be there is a trick to assign non existing shaders ?

Message 4 of 7
in reply to: idizdar

You can use the user data shaders to control an aiSwitch shader.

set_parameter operators can assign existing shaders.

// Stephen Blair
// Arnold Renderer Support
Message 5 of 7
in reply to: idizdar

You should be able to use user parameters to drive the shader assignment. Let me provide a couple of examples that might be of use.

Let's say you've exported some geo with some user data from Houdini to an .ass file (see standin.ass attached below as a trivial example).

Then depending on your preferred workflow, you can set things up in different ways to utilise the user data. I'll provide 2 examples below which uses the set_parameter operator and attached standin file (just 3 spheres with some arbitrary user data).

Example 1

Here, we assign a green shader to spheres that have particular string and velocity user properties

selection "sphere*.(my_string == 'make_me_green' and my_speed > 4.0)"
assignment "shader = 'green'"

sphere2 in standin.ass matches this criteria so it'll be assigned the green shader.

Example 2

You can also use the user data directly in the assignment. sphere1 and sphere3 have a my_shader_name user data with the values red and blue, respectively.

Here, the selection matches all spheres where the my_shader_name user data exists, and the assignment assigns the shader using the user data value as the shader name.

selection "sphere*.(my_shader_name)"
assignment "shader = my_shader_name"

The expected render and .ass files are attached and it should be easy to replicate in Maya using a standin. Hope this helps.




Message 6 of 7
in reply to: idizdar

Thanks Orn !

That is really good to know that Arnold can handle such things.

The problem now is that I d'ont have the same result as you in Maya.

I import you test.ass in Maya it render well but I get only the green sphere shaded, not the red and blue.

Seams to be it don't understand your assign_stuff operator.

Any idea to make it work in Maya ?

Message 7 of 7
in reply to: idizdar

How do you "set directly" ? You are using setAttr, not the Attribute Editor?

// Stephen Blair
// Arnold Renderer Support

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

Post to forums  

Technology Administrators