J_spad Posted February 27, 2014 Share Posted February 27, 2014 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 Quote Link to comment Share on other sites More sharing options...
Guest tar Posted February 27, 2014 Share Posted February 27, 2014 have you tried the Data Tree view, - Object Appearance - select all and then select the material Quote Link to comment Share on other sites More sharing options...
J_spad Posted February 27, 2014 Author Share Posted February 27, 2014 Thank you for the suggestion however it still wants be to attach per geo node. Quote Link to comment Share on other sites More sharing options...
J_spad Posted February 27, 2014 Author Share Posted February 27, 2014 (edited) 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 February 27, 2014 by J_spad Quote Link to comment Share on other sites More sharing options...
J_spad Posted February 27, 2014 Author Share Posted February 27, 2014 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? Quote Link to comment Share on other sites More sharing options...
J_spad Posted February 28, 2014 Author Share Posted February 28, 2014 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')) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.