Hi,
I want to create a file that is filled with particle positions. Something like that:
1,2,3
3,2,1
2,2,0
These would be the x,y,z positions of particles.
Can I do this kind of stuff with a filedata node? Or a file node in conjunction with a vex node? Or do I need to use Python for this kind of task?
Best wishes,
Thomas
Writing file with particle data
1953 2 0- ThomasSchwenke
- Member
- 30 posts
- Joined: Nov. 2016
- Offline
- Enivob
- Member
- 2537 posts
- Joined: June 2008
- Offline
AFAIK Vex can't write to a file. So Python might be the way to go.
The File node can write to several modern and legacy formats, is there a reason why you are inventing a new format?
Here is a small snippet of the default sphere written out to .RIB format. Maybe you could just cut and paste data from a RIB file into your own format..?
The File node can write to several modern and legacy formats, is there a reason why you are inventing a new format?
Here is a small snippet of the default sphere written out to .RIB format. Maybe you could just cut and paste data from a RIB file into your own format..?
"P" [ -2.111098e-08 0.5 -5.656685e-09 3.646268e-08 -0.5 9.770174e-09 0.1294095 0.4829629 0 0.125 0.4829629 -0.03349365 0.1120719 0.4829629 -0.06470477 0.09150636 0.4829629 -0.09150636 0.06470476 0.4829629 -0.112072 0.03349366 0.4829629 -0.125 9.770148e-09 0.4829629 -0.1294095 -0.03349364 0.4829629 -0.125 -0.06470475 0.4829629 -0.112072 -0.09150634 0.4829629 -0.09150638 -0.1120719 0.4829629 -0.0647048 -0.125 0.4829629 -0.03349369 -0.1294095 0.4829629 -5.039393e-08 -0.125 0.4829629 0.0334936 -0.112072 0.4829629 0.06470472 -0.09150641 0.4829629 0.09150631 -0.06470481 0.4829629 0.1120719 -0.0334937 0.4829629 0.125 -6.016408e-08 0.4829629 0.1294095 0.03349359 0.4829629 0.125 0.0647047 0.4829629 0.112072 0.0915063 0.4829629 0.09150642 0.1120719 0.4829629 0.06470484 0.125 0.4829629 0.03349375 0.25 0.4330127 0 0.2414814 0.4330127 -0.06470475 0.2165063 0.4330127 -0.125 0.1767767 0.4330127 -0.1767767 0.125 0.4330127 -0.2165063 0.06470476 0.4330127 -0.2414814 1.887447e-08 0.4330127 -0.25 -0.06470472 0.4330127 -0.2414815
Edited by Enivob - Dec. 14, 2016 13:08:29
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
- ThomasSchwenke
- Member
- 30 posts
- Joined: Nov. 2016
- Offline
Hi,
Thx for your response. A Python node attached to the import_source node does the trick. The specification is according to Otoys scatter node: https://docs.otoy.com/#standalone-v3-geometry-the-scatter-node [docs.otoy.com]
Source code below…
Best wishes,
Thomas
Thx for your response. A Python node attached to the import_source node does the trick. The specification is according to Otoys scatter node: https://docs.otoy.com/#standalone-v3-geometry-the-scatter-node [docs.otoy.com]
Source code below…
node = hou.pwd() geo = node.geometry() # save scatter csv file # create or replace file csvfile = open("I:/test/scatter"+str(hou.intFrame())+".csv","w") # iterate through points and # save positions for each point for point in geo.points(): pos = point.position() # pos x csvfile.write("1 0 0 ") csvfile.write(str(pos[0])) # pos y csvfile.write(" 0 1 0 ") csvfile.write(str(pos[1])) # pos z csvfile.write(" 0 0 1 ") csvfile.write(str(pos[2])) # start new line csvfile.write("\n") # close file csvfile.close()
Best wishes,
Thomas
Edited by ThomasSchwenke - Dec. 15, 2016 08:34:38
-
- Quick Links