Jump to content

New materials based on s@name attribute


forbidden14

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 

aaaaaaaaaaaaaa.png

Link to comment
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.

 

material_name_attrib.thumb.png.f0d3870730fc5a3ac1d8c0e9e5b17bc7.png

material_name_attrib.hip

Edited by JXS
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...