vrman Posted September 14, 2017 Share Posted September 14, 2017 (edited) Hey guys is there any way to execute string in python ? its my string variable : "hou.parm('/obj/test3_FBX/materials/Google_Hybrid___7/Google_Hybrid___7_surface/map1')" i want to use it to set a parameter , but problem is its a string. im also tried to change it like this : myPath = '/obj/test3_FBX/materials/Google_Hybrid___7/Google_Hybrid___7_surface/map1' hou.parm(myPath) in 3dsmax maxscript you can using a execute syntax before string to do it. is there a similar way in python for that ? Edited September 14, 2017 by vrman Quote Link to comment Share on other sites More sharing options...
davpe Posted September 14, 2017 Share Posted September 14, 2017 i think you need to type something like this: hou.node('your_node').parm('parm_name').set('string_you_want') so you first need pointer to a node, then point to a parameter you want to modify and then set a value. cheers, D. Quote Link to comment Share on other sites More sharing options...
vrman Posted September 14, 2017 Author Share Posted September 14, 2017 (edited) 37 minutes ago, davpe said: i think you need to type something like this: hou.node('your_node').parm('parm_name').set('string_you_want') so you first need pointer to a node, then point to a parameter you want to modify and then set a value. cheers, D. the problem is , i want to to execute that to get texture path and then use that path to set something myPath = '/obj/test3_FBX/materials/Google_Hybrid___7/Google_Hybrid___7_surface/map1' hou.parm(myPath) here is the full code : myNodes = hou.selectedNodes() mySize = len(myNodes) for i in range(mySize): myNode = '/obj/geo1/'+myNodes[i-1].name() myShop = (myNodes[i-1].geometry().primAttribs()[0]).name() myShopATT = myNodes[i-1].geometry().primStringAttribValues(myShop)[0] myPath = 'hou.parm('+'"'+myShopATT+'/'+myShopATT.replace('/obj/test3_FBX/materials/','')+'/map1")' print myPath hou.node(myNode).parm('Texture').set(myPath) i want to execute myPath before use it to set Texture parm. its return this now : but it should be like this : Edited September 14, 2017 by vrman Quote Link to comment Share on other sites More sharing options...
davpe Posted September 14, 2017 Share Posted September 14, 2017 (edited) i think these lines myShop = (myNodes[i-1].geometry().primAttribs()[0]).name() myShopATT = myNodes[i-1].geometry().primStringAttribValues(myShop)[0] don't make sense. what exactly are you trying to achieve? also, you're missing #import hou Edited September 14, 2017 by davpe Quote Link to comment Share on other sites More sharing options...
vrman Posted September 14, 2017 Author Share Posted September 14, 2017 2 minutes ago, davpe said: i think these lines myShop = (myNodes[i-1].geometry().primAttribs()[0]).name() myShopATT = myNodes[i-1].geometry().primStringAttribValues(myShop)[0] don't make sense. what exactly are you trying to achieve? also, you're missing #import hou i have 20 group prim , and there is 20 material for them , i want to get texture disk path from each material , and use it to set something . its shelf tool , dont need import hou Quote Link to comment Share on other sites More sharing options...
davpe Posted September 14, 2017 Share Posted September 14, 2017 well... I'm no python expert but I would approach it this way: mat = hou.node('mat').children() geo = hou.node('obj/box_object1/material1').geometry() attrib = geo.primStringAttribValues('str') counter = -1 for i in mat: counter += 1 value = attrib[counter] i.parm('basecolor_texture').set('C:/'+str(value)+'.exr') it takes string prim attribute (possibly based on group names) and returns a tuple with all the attribute values. then in loop you can insert values into texture paths on materials (or anywhere). not sure if that is exactly what you're after thou... Quote Link to comment Share on other sites More sharing options...
f1480187 Posted September 14, 2017 Share Posted September 14, 2017 Try this: hou.parm('/obj/test3_FBX/materials/Google_Hybrid___7/Google_Hybrid___7_surface/map1').eval() There are many ways to get and set parms in HOM. Here is some of them: >>> hou.evalParm('/mat/principledshader1/basecolor_texture') 'C:/PROGRA~1/SIDEEF~1/HOUDIN~1.705/houdini/pic/texture/rocks001_basecolor.rat' >>> hou.parm('/mat/principledshader1/basecolor_texture').set('C:/some/path/to/file.jpg') >>> hou.evalParm('/mat/principledshader1/basecolor_texture') 'C:/some/path/to/file.jpg' >>> p = hou.parm('/mat/principledshader1/basecolor_texture') >>> p.eval() 'C:/some/path/to/file.jpg' >>> p.set('C:/some/other/path.exr') >>> p.eval() 'C:/some/other/path.exr' >>> node = hou.node('/mat/principledshader1') >>> p = node.parm('basecolor_texture') >>> p.eval() 'C:/some/other/path.exr' >>> p.set('Mandril.pic') >>> p.eval() 'Mandril.pic' Quote Link to comment Share on other sites More sharing options...
vrman Posted September 14, 2017 Author Share Posted September 14, 2017 1 hour ago, f1480187 said: Try this: hou.parm('/obj/test3_FBX/materials/Google_Hybrid___7/Google_Hybrid___7_surface/map1').eval() There are many ways to get and set parms in HOM. Here is some of them: >>> hou.evalParm('/mat/principledshader1/basecolor_texture') 'C:/PROGRA~1/SIDEEF~1/HOUDIN~1.705/houdini/pic/texture/rocks001_basecolor.rat' >>> hou.parm('/mat/principledshader1/basecolor_texture').set('C:/some/path/to/file.jpg') >>> hou.evalParm('/mat/principledshader1/basecolor_texture') 'C:/some/path/to/file.jpg' >>> p = hou.parm('/mat/principledshader1/basecolor_texture') >>> p.eval() 'C:/some/path/to/file.jpg' >>> p.set('C:/some/other/path.exr') >>> p.eval() 'C:/some/other/path.exr' >>> node = hou.node('/mat/principledshader1') >>> p = node.parm('basecolor_texture') >>> p.eval() 'C:/some/other/path.exr' >>> p.set('Mandril.pic') >>> p.eval() 'Mandril.pic' not working in my case , i got this "AttributeError: 'NoneType' object has no attribute 'eval'" error after running this : myPath = "'"+myShopATT+'/'+myShopATT.replace('/obj/test3_FBX/materials/','')+"_surface"+'/map1'+"'" hou.parm(myPath).eval() Quote Link to comment Share on other sites More sharing options...
f1480187 Posted September 14, 2017 Share Posted September 14, 2017 Don't add extra quotes. Quote Link to comment Share on other sites More sharing options...
vrman Posted September 14, 2017 Author Share Posted September 14, 2017 4 hours ago, f1480187 said: Don't add extra quotes. its working now , thank you so much 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.