hou.Volume.voxel

   4952   5   2
User Avatar
Member
789 posts
Joined: April 2020
Offline
Hello all,

I am playing with the HOM acces to volumes. As a simple test I am trying to get the values from all the voxels,

The code I am trying in a python sop:

# This code is called when instances of this SOP cook.
geo = hou.pwd().geometry()

# Add code to modify the contents of geo.
for prim in geo.prims():
if (prim.type() == hou.primType.Volume):
res = prim.resolution()
for i in range(res*res*res):
dens = prim.voxel(i)


I run into a problem in the voxel(i) call. The sop has an error message that looks something like:

…./hou.py line 18400 in voxel,
return _hou.Volume_voxel(*args)
Type error in method Volume_voxel, argument 2 of type `std::vector<float…


Does the volume voxel require a vector? Perhaps it expects the position instead of an index?

Any help is appreciated.

Koen
User Avatar
Staff
809 posts
Joined: July 2006
Offline
It looks like any iterable triple works, meaning either a tuple like:

prim.voxel((i,j,k))

a list

prim.voxel()

or a hou.Vector3

idx = hou.Vector3(i,j,k)
prim.voxel(idx)
User Avatar
Member
789 posts
Joined: April 2020
Offline
Perfect, thanks!
(Just out of curiosity, how did you find this out?)

Koen
User Avatar
Member
789 posts
Joined: April 2020
Offline
One more question:
Is there a python funcion to set the value of a voxel?

Cheers,
Koen
User Avatar
Member
12466 posts
Joined: July 2005
Online
I don't think you can create volumes yet, can you?
Jason Iversen, Technology Supervisor & FX Pipeline/R+D Lead @ Weta FX
also, http://www.odforce.net [www.odforce.net]
User Avatar
Member
789 posts
Joined: April 2020
Offline
Dont think so. I was just playing with a python sop to modify an existing volume. I want to implent a “flood-fill” for volumes with a noise in it. Getting to the information seems very simple, changing the values seems a little harder right now.

Back to the particle/dops flood filling, if only I could get gas_field_to_particle to work correctly :-)

Cheers,
koen
  • Quick Links