boneCapture to array of floats script!

   3230   1   4
User Avatar
Staff
476 posts
Joined: April 2014
Offline
Hy guys,
I was trying to access boneCapture attribute used for deformation in VOP and I managed to find a solution by using Python to convert the infamous IndexPair attribute to a per point array of weights.
I couln't find a clear solution to that problem online, so I'm sharing it.

Put that python code in a Python SOP and connect the node after a Capture SOP.
With that, you can use the Capture Painting to paint normalized regions on a mesh and actually use the region maps in VOP.

node = hou.pwd()
geo = node.geometry()
inName = “boneCapture”
outName = “boneCaptureWeights”

# Find the boneCapture array and get the table and the number of regions
boneCapture_attribute = geo.findPointAttrib(inName)
table = boneCapture_attribute.indexPairPropertyTables()
num_indices = table.numIndices()

# Create the weights per point array
default_val_weight = * (num_indices)
weights_attribute = geo.addAttrib( hou.attribType.Point, outName, default_val_weight, create_local_variable=False )

for point in geo.points():
# Extract only the weights into a single array dicthing the indices
val_weight = * (num_indices)

iw = point.floatListAttribValue( boneCapture_attribute )
for k in range(num_indices):
i = int(iw)
if i!=-1:
w = iw
val_weight = w
point.setAttribValue( weights_attribute, val_weight )
User Avatar
Member
7025 posts
Joined: July 2005
Offline
Man, I could have used that in 2006!



Thanks for that, Python FTW!
  • Quick Links