Using Python to export data

   3379   1   1
User Avatar
Member
11 posts
Joined: 7月 2015
Offline
Hi.

I have written a network to simulate a boid. Now I want to take the result of the simulation to do statistical analysis. For this I need to take the position for each point and process it outside Houdini. Is possible take the information for each point and for each frame and then write to a file using the python api?

If yes may you point me to some basic example?

Thanks a lot!
Juan Camilo Acosta Arango
ja0335@gmail.com
User Avatar
Member
636 posts
Joined: 6月 2006
Offline
This is a simple obj exporter. you can see it's preety simple to export the data to a file.

for testing this use a python wrangler and pipe a mesh file with normals into it. change also the filepathname!

what you can do is to make a cvs exporter so you can use it in nearly any tool.


# Quick and Dirty OBJ Exporter

node = hou.pwd()
geo = node.geometry()

# Add code to modify contents of geo.
# Use drop down menu to select examples.

points =
for point in geo.points():
points.append(“v ” + str(point.position()) + “ ” + str(point.position()) + “ ” + str(point.position()) + “\n”)

pNormals =
for point in geo.points():
pNormals.append(“vn ”)
for n in point.attribValue(“N”):
pNormals.append(str(n) + “ ”)
pNormals.append(“\n”)

faces =
for prims in geo.prims():
p =
p.append(“i”)
for vertices in prims.vertices():
p.append(str(vertices.point().number()+1)) #there is no face with a value of 0 => +1
p.append(“\n”)
faces.append(' ‘.join(p))

# Export OBJ Data
file_obj = ’C:\\dev\\houdini.obj'
f_out = open(file_obj, ‘w’)
f_out.write(“g\n”)
f_out.write(''.join(points))
f_out.write(“g\n”)
f_out.write(''.join(pNormals))
f_out.write(“g\n”)
f_out.write(''.join(faces))
f_out.close()

Attachments:
OBJ_Exporter.hipnc (49.6 KB)

  • Quick Links