GrahamDClark

GrahamDClark

About Me

Connect

LOCATION
Not Specified
ウェブサイト

Houdini Skills

Availability

Not Specified

Recent Forum Posts

Running Python 3 scripts in Houdini as a Subprocess 2023年12月20日0:38

bigbalabong, thank you! -E worked here for subprocess

USD import lops, arrays dif lengths points vertex, TOP way? 2023年4月22日6:07

EDIT#4: Yes I keep editing it, and talk to myself.
I have a python script that iterates over USD curves and their point attributes and does various stuff with them.
Trying to migrate that script to TOPs has been frustrating as I don't really get how to assemble the data to then run over it using mostly TOPs vs mostly Python.

So with Geometry Import TOP we get elements and the attributes at least come in as P 0.0,1.0,0.0 etc but even then I'd need to make worktimes or maybe partions for each subcurve.

With USD import TOP I can expand curveVertexCounts to get a workitem per subcurve of the basis curve. But that Expand breaks my by frame serial loop (serial because I'm driving other apps per frame).

1. I don't see a way to unflatten the points to subcurves, and then a set of 3 for xyz, using TOPs, just via python see below example script. Not an issue just curious as I would have thought there was a TOPs way. Do we correlate points of subitems to their element attributes using python, or is their a TOPS way (especially in a serial loop with multiple prims and subcurves?
2. The issue is that Expand TOP wont work when going over a frame range using partition by frame TOP for a serial loop TOP, so I have to revert to enumerating over the subcurves and then extracting its points inside a Python Script TOP. I was hoping to be able to have a TOPs loop over frames and inside a TOPs loop over subcurves. I've tried putting the expand TOP inside and outside of loop, guessing we cant have a loop based on a parition by subcurve work_items inside a loop based on partition by frame.

I would like to try to get this working in TOPs, as I think, like my setups in Touchdesigner, having a nodal tool structure offers a lot of speedy flexibility.

# Executes a Python script, either in process or as a job
import numpy as np

# Get curveVertexCounts and points attributes
curves = work_item.attrib("curveVertexCounts").values
points = work_item.attrib("points").values

# Calculate the starting and ending indices for the points of the current subcurve
start_idx = int(3 * np.sum(curves[:work_item.index]))
end_idx = int(3 * np.sum(curves[:work_item.index + 1]))

# Extract the points for the current subcurve
subcurve_points = points[start_idx:end_idx]

# Print the results
print("Subcurve: ", work_item.index)
#print("curveVertexCounts: ", curves)
#print("points: ", points)
print("Subcurve points: ", subcurve_points)

Retime USD 2023年4月18日5:07

thank you! will stick with the python and try your suggestion to avoid hou.frame() (and better as i mod it for files).