setting Python relative reference

   2815   3   1
User Avatar
Member
3 posts
Joined: July 2020
Offline
So im back into python and come across 1 problem i can't figure out.

so what i want to do is get the selected arnoldImage node and set that to another usdUvTexture node.
All work fine if you run it once.

so the relative path is set automaticly and in the usdUvTexture node in the file i get `chs("../ARN_new/BaseColor/filename")`
wich is correct as it is the relative path to the arnoldImage node

but as soon as i run it another time to update it so it should put `chs("../ARN_new/Roughness/filename")` in the node it doesnt work.

As it automatically fills in the ref and instead of updating the usdUvTexture node it fills it in the arnoldImage.

is there any way to solve this

import sys
import toolutils
import hou

##make selection
selectedNode = hou.selectedNodes()[0]
selectedNodeName = str(selectedNode)
nodeType = hou.nodeType(selectedNode.path())

##get parent name and contex path (Arnold material Builder)
arnoldMatBuilder = selectedNode.parent()
arnoldMatBuilderConnection = arnoldMatBuilder.outputs()
arnoldMatBuilderPath = arnoldMatBuilder.parent().path()
arnoldMatBuilderName = str(arnoldMatBuilder)
amb = hou.node(arnoldMatBuilderPath)

texRef = str('`chs("../'+ arnoldMatBuilderName + '/' + selectedNodeName + '/filename")`')

usd_tex_base = hou.node(arnoldMatBuilderPath + '/' + "USD_tex_BaseColor_" + (arnoldMatBuilderName[4:]))

usd_tex_base.parm('file').set(texRef)
User Avatar
Member
2658 posts
Joined: June 2008
Offline
Maybe you need to use setExpression() instead of set()?
https://www.sidefx.com/docs/houdini/hom/hou/Parm.html [www.sidefx.com]
Using Houdini Indie 20.5
Windows 11 64GB Ryzen 16 core.
nVidia 3060RTX 12BG RAM.
User Avatar
Member
3 posts
Joined: July 2020
Offline
I tried than unfortunately that didn't work.
Or at least it sets the expression correct but also adds a key frame or some sort. (the .parm becomes green in the node)
So the relative reference doesn't work then.

So if people have a solution for this that would be perfect to
User Avatar
Member
3 posts
Joined: July 2020
Offline
Ok it's a bit of an ugly solution and if anyone has a proper i would really like to know.
But for now i gist set .revertToDefaults() and then rund the part to set relative ref again.

This works for now

Cheers
Robert
  • Quick Links