Programatically create objects and access its properties.

I’m having a hard time trying to find the way to achieve this. Maybe I’m not using the proper words to search but haven’t found anything on Google or this forum yet. I’d like to create a series of objects programmatically and still keep them identified so I can modify their properties individually or by group. Let’s say somewhere I have something like:

id=0
for x in range(0, 99):
   for y in range(0, 99):
    s[id]=new Sphere() #making this up, I have no idea...
    s[id].x=x
    s[id].y=y
    s[id].z=x+y
    s[id].radius=0.5
    id+=1

That would just create 10,000 spheres and give then an initial position. Then at anytime let’s say, change some of their sizes by using something like:

id=1500
for i in range(0, 200):
    s[id].radius=1.5
    #or even better calling a function that animates the property
    id=id+4

Does this makes any sense? Is this a reasonable way of creating and accessing geometry in TD?
I’m just trying to do this zoada.com/lpa/ and instead of using controls, make it audio reactive.

You want instancing. Matthew Ragan has great tutorials on this on YouTube. If you’re looking to created 100s-1000s of instances, i would also invest in his Make Some Noise series, it’s long, and dense, but there’s a lot of great info for dealing with lots of computations, even if you don’t get into the GLSL stuff.

To operate entirely through Python, if we consider real-time performance, there are several ways to think about it:

  1. Create a structured numpy.array and store it via OP.store(), then manipulate it. Then extract it with script CHOP, then Instance (if you want to have different shapes, you can use different numbers to identify different CHOPs and then individual instances)

  2. Create some points using the model SOP, using the built-in and custom attributes, then:
    a. Use this sop directly to Instance.
    b. Use Geometry shader to create various shapes based on the attributes of the points

  3. Find a way to manipulate the Compute Shader using Python (convert each command to an array), then:
    a. Use this texture directly to Instance.
    b. Use the Geometry shader to create a variety of different shapes based on the values of each pixel.

Of course, if you don’t have frequent, large-scale parallel operations, and only require static results, then using table DAT+replicator COMP is also a more intuitive method (or table DAT+Instance).