Getting a Geometry File using a Python string

   3865   2   1
User Avatar
Member
5 posts
Joined: 2月 2015
Offline
Hi everyone!

I'm trying to get a file run some operations and then save a new file using Python to set file paths, but I can't for the life of me get it to work.

Basic Python to build the file path:
name = 'SM_Floor_3x3_01_High'

highStart = 'S:/Jona_Marklund/_P3/Sculpts/'
lowStart = '"S:/Jona_Marklund/_P3/Low/'

highEnd = '.OBJ'
lowEnd = '.fbx'

highName = highStart + name + highEnd


name = name.replace('_High', '')

lowName = lowStart + name + lowEnd

print highName
print lowName

So, I want to push “highName” into file2's Geometry File field and load that file.


And push “lowName” into rop_fbx1's Output File field and be able to Save to Disk.


Would love to get some input on how I could do this.

Best Regards
//Jona
User Avatar
Member
3 posts
Joined: 9月 2014
Offline
Something like this?
fileNode = hou.node(“../file2”)
fileNode.parm(“file”).set(highName)

You can drag the fbx node into the python to get the path to the node. Hover over parameters to know what they are called behind the scenes.

fbxNode = hou.node(“/rop/rop_fbx1”)
fbxNode.parm(“execute”).pressButton()
User Avatar
Member
5 posts
Joined: 2月 2015
Offline
Yes!

Thank you Patrick, that worked perfectly!

Learned something new today, even more thanks for that!

Here's the final code snippet should anyone stumble upon this thread in the future.

#Input .obj name
name = 'SM_Floor_3x3_01_High'

#Path where the .obj is located
highStart = 'S:/Jona_Marklund/_P3/Sculpts/'
#Path where the .fbx is to be saved
lowStart = 'S:/Jona_Marklund/_P3/Low/'

#Extensions
highEnd = '.OBJ'
lowEnd = '.fbx'

#Build the final .obj path
highPath = highStart + name + highEnd

#Remove "_High" to follow the naming convention of the project
name = name.replace('_High', '')

#Build the final .fbx path
lowPath = lowStart + name + lowEnd

#Get the input file node for .obj input
fileNode = hou.node("../file2")
#Get the rop_fbx node for .fbx eport
fbxNode = hou.node("../rop_fbx1")

#Set the "file" paramater to final path
fileNode.parm("file").set(highPath)
#Set the "sououtput" paramater to final path
fbxNode.parm("sopoutput").set(lowPath)

#Test strings
#print highName
#print lowName
  • Quick Links