Hi, I'm looking at exporting some attribute data from my geometry objects in a custom format using python.
It would seem using a ROP network Shell node with a Pre-Render Script would be the best bet.
Unfortunately i have no idea how to setup the export.py file to access the hou module or get a the geometries in the scene.
First off, pointing the Pre-Render Script to even an empty *.py file throws an error on the Shell node :
"Error: Python Error: Syntax Error: ('invalid syntax', ('<stdin>', 1, 2, ‘theFilename\n’))
Does that mean the parameter-box is trying to run the script file-path to run as the actual python script? If so, surely that's a bug?
Also, how do i setup the code in the script.py file to access houdini data in the scene? I assume the pre-render script isn't called per object / doesn't know what the current geometry is or anything.
Cheers, H
Export Geometry with Python ROP Pre-RenderScript [fixed]
5547 1 0- hjd
- Member
- 11 posts
- Joined: 10月 2013
- Offline
- hjd
- Member
- 11 posts
- Joined: 10月 2013
- Offline
It seems the path-as-script bug has been around for a while:
http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=10077&view=next&sid=d45e6d5971f15f87be462cd5650b7d41 [sidefx.com]
After fixing that , the rest was fairly simple:
node = hou.pwd() #this is the ROP Shell node
expRoot = node.parm('expRoot') #get the custom addded parameter
if expRoot != None:
geoNode = hou.node( expRoot.eval() ) #get the node for the export-root
geo = geoNode.geometry()
# extract paths from primitives
outPaths = “”
pathAtt = geo.findPrimAttrib(“path”)
for prim in geo.prims():
outPaths += prim.attribValue(pathAtt)
outPaths += “\r\n”
fp = open(“cfoo.txt”,“wt”)
if fp:
fp.write(outPaths)
fp.close()
http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=10077&view=next&sid=d45e6d5971f15f87be462cd5650b7d41 [sidefx.com]
After fixing that , the rest was fairly simple:
node = hou.pwd() #this is the ROP Shell node
expRoot = node.parm('expRoot') #get the custom addded parameter
if expRoot != None:
geoNode = hou.node( expRoot.eval() ) #get the node for the export-root
geo = geoNode.geometry()
# extract paths from primitives
outPaths = “”
pathAtt = geo.findPrimAttrib(“path”)
for prim in geo.prims():
outPaths += prim.attribValue(pathAtt)
outPaths += “\r\n”
fp = open(“cfoo.txt”,“wt”)
if fp:
fp.write(outPaths)
fp.close()
-
- Quick Links