Procedurally generate multiple curves using Python?

Hi TDs,

I’m new to TouchDesigner, but I’m experienced with programming and Houdini and VEX.

I’m running a Python script that runs a loop that generates a pattern of XY point positions. It runs this loop N times. Each time it runs, I want to end up with a separate curve.

What would be a good approach here?

I’m saving those points as rows in a table. And then using datTo CHOP to output tx and ty channels. I then use a chopTo SOP to generate my curves.

The problem with this approach is that all of the lines connect to each other. The end of 1 connects to the beginning of 2, etc.

I don’t know the number of curves beforehand. I want this to be procedural so I can generate 100 curves, without having to create 100 tables beforehand.

  • I considered saving separate columns for each new curve (The length of each curve is not uniform.) But I’d still have to find a way to export those all separately.
  • I considered saving the points as arrays instead of rows. But I don’t know how to turn an array into channel data.
  • I added a groupID column which increases each time I run the loop. I tried using the group SOP, but I don’t know how to make it use that number. And I don’t know how I’d export multiple groups if I did.
  • I could create a Line SOP with more than enough points, copy it N times, and then just set the point positions. And then delete the extra points at the end. (Because not all of the curves will have the same number of points.)

In Houdini, I would generate the lines in the code itself. So each time I made the loop, I would just make a new primitive object and store the points in there. Is there a similar approach in TD?

Thanks!

I think I’ve found my answer. I think I need to use the scriptSOP instead of just a generic script operator passing out numbers.

I’m investigating the addPoints() method on scriptSOP now. :smiley:

1 Like