ben Posted September 7, 2012 Share Posted September 7, 2012 Hi, I would like to rename materials according to a parameter. I expected something like that to work : MyMat_`chs(« ../../CONTROL/MatName ») `_A But unfortunately it doesn’t… Any ideas ? thx Quote Link to comment Share on other sites More sharing options...
hopbin9 Posted September 7, 2012 Share Posted September 7, 2012 You can't use hscript in the name of a node. This can easily be done using the callback of the parameter. Here's an example using Python. hou.node("../../material_node").setName("MyMat_"+kwargs["node"].evalParm("MatName")+"_A") Quote Link to comment Share on other sites More sharing options...
motionprojects Posted September 7, 2012 Share Posted September 7, 2012 I'm trying to do something similar. When you load a geometry file with the "`" key get a geometry node automatically named for the file sop's file string. I would like this to persist, so that choosing a different file will again rename the geometry node. I've not done any python expressions or callbacks before, so thanks in advance for the guidance. Quote Link to comment Share on other sites More sharing options...
hopbin9 Posted September 7, 2012 Share Posted September 7, 2012 (edited) I'm trying to do something similar. When you load a geometry file with the "`" key get a geometry node automatically named for the file sop's file string. I would like this to persist, so that choosing a different file will again rename the geometry node. I've not done any python expressions or callbacks before, so thanks in advance for the guidance. Seriously did not know that ` was a short cut for loading a file. Thanks I don't think something like that is very hard. Add the following to the callback for a file parameter in your asset. import os; kwargs["node"].setName(os.path.basename(kwargs["node"].evalParm("file"))) Where "file" is the parameter name that should be used to set the node's name. EDIT: Make sure you set the callback to Python. Edited September 7, 2012 by hopbin9 Quote Link to comment Share on other sites More sharing options...
ben Posted September 8, 2012 Author Share Posted September 8, 2012 Thanks ! The callback will do the trick. 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.