Jump to content

Apply shader to all objects in an alimbic


J_spad

Recommended Posts

Hello,

 

I do not normally post requests like this due to wanting to learn things for myself however I am under the gun. Can someone tell me how to loop through an alembic and assign a shader to all geometry nodes brought in? I have an alembic with 200+ objects on different levels of depth within the alembic and need to apply the same shader to all of them. I have tried just selecting and applying but it only works if I do the assigning one object at a time. 

 

Thanks!

James S

 

Link to comment
Share on other sites

So I got some python going but when I loop through it is unable to skip nodes that do that have the material path attribute. How do I add a conditional to only run the material assignment if it is a geo node?

 

>>> def print_tree(node, indent=0):

...     for child in node.children():

...         childaccess = child

...         matAssign = childaccess.parm('shop_materalpath')

...         matAssign.set('/shop/BoatSteel')     

Edited by J_spad
Link to comment
Share on other sites

I was able to get this output from this script:

 

>>> def assignMat(node):

...     for child in node.children():
...             childaccess = child
...             try:
...                     matAssign = childaccess.parm('shop_materalpath')
...                     matAssign.set('/shop/BoatSteel')
...                     print "Parm on Node! %s" %(childaccess)      
...             except:
...                     print "No parm on Node %s" %(childaccess) 
... 
>>> assignMat(hou.node('/obj/animation/animationExport/css_atlanta_v17_css_atlanta'))
No parm on Node css_atlanta_v19_for_animation_css_atlanta
No parm on Node boatBody
No parm on Node boatBody1
No parm on Node Greats
 
It seems to only be checking the top level on  nodes. Any ideas on how I can go deeper?
Link to comment
Share on other sites

Was able to get it working! If anyone needs to mass assign a shader to all the children of a node.....

 

def assignMat(node):
for child in node.allSubChildren():
matAssign = child.parm('shop_materialpath')
if matAssign:
print "Parm found on Node......"  
matAssign.set('/shop/myshader')
print "Parm on Node! %s" %(child)      
else:
print "Parm not assigned to Node %s" %(child) 
 
assignMat(hou.node('/obj/mynode'))
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...