danielsweeney Posted March 19, 2021 Share Posted March 19, 2021 Hi Everyone, can anyone give me a heads up on how to do this? if I want to set a relative reference I usually do something like this. node = hou.node('/obj/geo1/') p1 = node.parm('sphere1/scale') p2 = node.parm('sphere2/scale') p2.set(p1) but what if I want the path to be an absolute reference? cheers for your help. D Quote Link to comment Share on other sites More sharing options...
jfaulkner Posted March 19, 2021 Share Posted March 19, 2021 You could build an expression pointing to the parm instead, something like this node_one = hou.node("/obj/geo1/sphere1") node_two = hou.node("/obj/geo1/sphere2") node_two.parm("scale").setExpression('chs("' + node_one.path() + '/scale")') Quote Link to comment Share on other sites More sharing options...
danielsweeney Posted March 20, 2021 Author Share Posted March 20, 2021 ah ok. so just do it manually. just didn't know if there was a more elegant solution. and you can set absolute reference with right-click. thought there might be a function for it. cheers for the help. D Quote Link to comment Share on other sites More sharing options...
Benyee Posted August 26, 2021 Share Posted August 26, 2021 (edited) import string def abs_path_reference(node): parms = node.parms() #filter string type parameters refParms = [] for i in parms: if i.rawValue().find('ch("../')!=-1: refParms.append(i) print str( len(refParms) ) + " parameters channel referenced and modified to:" #loop for finding out node(s) which channels reference from for parm in refParms: orig_expr=parm.rawValue() absPathStrs=[] relPathStrs=[] for i in parm.rawValue().split('('): for j in i.split(')'): if j.find('../')!=-1: tmp1=j.split('/') tmp1.pop() tmp2='/'.join(tmp1) relNodePath=tmp2[1:len(tmp2)] refNode=node.node(relNodePath) absNodePath=refNode.path() absPathStrs.append(absNodePath) relPathStrs.append(relNodePath) #setting new expressions new_expr=orig_expr for index in range(len(relPathStrs)): count=new_expr.count(relPathStrs[index]) new_expr=new_expr.replace(relPathStrs[index],absPathStrs[index],count) print new_expr parm.setExpression(new_expr) print "-------------------------------------------" #excute script sels = hou.selectedNodes() for sel in sels: abs_path_reference(sel) hello daniel,this is some code for modifying from relative to absolute path in channel reference,i don't know whether it's a complete solution,but it could be useful in some situation,hope helpful Edited August 26, 2021 by Benyee 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.