Jump to content
Sign in to follow this  

New materials based on s@name attribute

Recommended Posts

Hey all, 

  Think I'm pretty close to what I'm trying to do, but missing how to read the iteration attribute into python to create the material names.  

Basically I'm trying to make a material for every US state.  I'm making the 50 materials but they are all stuck on alabama then incrementing number added to alabama instead of the names other states.

I'd like to also assign the basecolor texture based on the s@state attribute that would be something like C:/filefolder/`@state`.jpg into the python script creating the material.  

I'm pretty new to python in any sense, and slapped some code together from stack overflow, so would appreciate any hand holding!  

Also if there is any other way to do this without creating the 50 textures and access a file path in a single texture in PDG,  would love to hear.  

Thanks in advance 


Share this post

Link to post
Share on other sites

Hi. Not sure if this is what you're looking for. Without a HIP file, I don't have much to work with but given what it is you're looking for, this is how I would go about it. Hope it helps!


I’m sure what your attempting to do is doable using the iterPrims() method, but in my case I simply tackled them all at once using the prims() method, extracted the “state” attribute on each loop and created a principled shader using the value of the attribute. I set up an additional file_path_dir string attribute which I also use to set the texture path parameter in the shader.




Edited by JXS

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this