Exporting Data from Geometry Spreadsheet
10854 5 5- jderry2019
- Member
- 10 posts
- Joined: 1月 2017
- Offline
I want to take a particle simulation and export the particle attributes in the geometry spreadsheet as a simple file format like .csv or .txt
My current approach is from this forum post [www.sidefx.com]: a Python script that will loop through the attributes and write it out to a file, but the script always returns an error “'module' object has no attribute ‘writeFireworks’”. The forum post was from Houdini 2011, and trying to load the .hip example file results in a 404 error.
So my question is this: is the script valid, and I'm just placing the node in the incorrect place? Is the script invalid since it's from Houdini 2011 and there's a new way to access the data? Or is Python scripting the wrong approach altogether?
I'm using the Houdini Apprentice 15.5.473, and below are some screenshots of the Python shell and my node network (I just plopped down the Location Particle Emitter shelf tool)
My current approach is from this forum post [www.sidefx.com]: a Python script that will loop through the attributes and write it out to a file, but the script always returns an error “'module' object has no attribute ‘writeFireworks’”. The forum post was from Houdini 2011, and trying to load the .hip example file results in a 404 error.
So my question is this: is the script valid, and I'm just placing the node in the incorrect place? Is the script invalid since it's from Houdini 2011 and there's a new way to access the data? Or is Python scripting the wrong approach altogether?
I'm using the Houdini Apprentice 15.5.473, and below are some screenshots of the Python shell and my node network (I just plopped down the Location Particle Emitter shelf tool)
- neil_math_comp
- Member
- 1743 posts
- Joined: 3月 2012
- Offline
The link you posted is to the Houdini 11.0 docs, specifically the old POPs (not in DOPs). The new POPs (in DOPs) was added in Houdini 12.5, and the old POPs has been hidden for a while.
A Python SOP is probably a reasonable approach. There might be a simpler approach, though I'm not familiar enough with the Python interface to suggest something simpler. However, it'd be invoked by just cooking the Python SOP, (e.g. setting the display flag on it and displaying it in the viewport, or alternatively, just middle-clicking on the node), not from a Python Shell pane.
Someone might have already made an asset to export to something like CSV automatically. I know I've made one to do the opposite.
A Python SOP is probably a reasonable approach. There might be a simpler approach, though I'm not familiar enough with the Python interface to suggest something simpler. However, it'd be invoked by just cooking the Python SOP, (e.g. setting the display flag on it and displaying it in the viewport, or alternatively, just middle-clicking on the node), not from a Python Shell pane.
Someone might have already made an asset to export to something like CSV automatically. I know I've made one to do the opposite.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
- jderry2019
- Member
- 10 posts
- Joined: 1月 2017
- Offline
Thanks for the speedy reply! Cooking the SOP was what did the trick! I have the final script just in case anyone is running into a similar problem. So now all I have to do is select the display flag and hit play, and a new csv file is generated per frame directly onto my Desktop (pretty messy, but manageable)
Thanks so much!
Thanks so much!
Edited by jderry2019 - 2018年6月15日 14:09:50
- mandrake0
- Member
- 644 posts
- Joined: 6月 2006
- Offline
Thanks to your Effort! i made a simple HDA.
Maybe i should have made a ROP Output Driver would have been better.
i wanted to upload to Orbolt but it was offline.
otherwise here is the Python Code:
Maybe i should have made a ROP Output Driver would have been better.
i wanted to upload to Orbolt but it was offline.
otherwise here is the Python Code:
node = hou.pwd() geo = node.geometry() # CONFIG filename = "test.csv" separator = "," # Get File f = file(filename, "w") # Create Column for attrib in geo.pointAttribs(): attrib_count = attrib.size() if 1 != attrib_count: for i in range(0,attrib_count): if i > 2: # if its a Multi Array f.write(attrib.name() + " [" + chr(94 + i) + "]" + separator) # ASCII to Char else: f.write(attrib.name() + " [" + chr(88 + i) + "]" + separator) # ASCII to Char else: f.write(attrib.name()) f.write(separator) f.write("\n") # Insert Points in File for point in geo.points(): for attrib in geo.pointAttribs(): attrib_count = attrib.size() if 1 != attrib_count: for i in range(0,attrib_count): f.write(str(point.attribValue(attrib)[i]) + separator) else: f.write(str(point.attribValue(attrib))) f.write(separator) f.write("\n") # Save the CSV File f.close()
Edited by mandrake0 - 2018年6月17日 17:40:33
- Cera
- Member
- 536 posts
- Joined: 7月 2009
- Offline
- Bruno Kindt
- Member
- 4 posts
- Joined: 12月 2015
- Offline
The “Game Development Toolset” also includes a “CSV Exporter”
https://www.sidefx.com/tutorials/game-development-toolset-overview/ [www.sidefx.com]
The HDA python script itself is https://github.com/sideeffects/GameDevelopmentToolset/blob/Development/otls/rop_csv_exporter.hda/gamedev_8_8Driver_1rop__csv__exporter/PythonModule [github.com]
https://www.sidefx.com/tutorials/game-development-toolset-overview/ [www.sidefx.com]
The HDA python script itself is https://github.com/sideeffects/GameDevelopmentToolset/blob/Development/otls/rop_csv_exporter.hda/gamedev_8_8Driver_1rop__csv__exporter/PythonModule [github.com]
-
- Quick Links