Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5846

Help with python recognizing each selected object in a list

$
0
0

@Noah_Medley wrote:

Hi!

I'm currently working on a project that has to do with generating blocks based on the number of blocks around them. I have a working script that generates the first state randomly giving values of 1 (on) or 0 (off) for each point on a grid so that the rest of the script can react to it using the logic that I insert (Kind of like cellular automata if you know what that is).

Anyways, now instead of randomly generating the first form, I want to be able to start out with a geometry that I manually put into rhino, and then have the logic work from there.

currently I have something like this

obj = rs.GetObjects ("select objects")

def SelectedObjects (xDimension, yDimension, zDimension, obj):
   arrStates = []
   for i in range (0, xDimension):
     for j in range (0, yDimension):
       for k in range (0, zDimension):
         for v in (obj):
           centroid = rs.CurveAreaCentroid (v)
           if centroid:
            print centroid

obj = rs.GetObjects ("select objects")
xDimension = 5
yDimension = 5
zDimension = 5

Sorry if this doesn't make sense. But what I want the script to do is spit out a list of centroids for each object in the list so that eventually I can say something like:

if centroid == 1
  arrv.append (1)

and do that for the other values i,j,k. This all leads up to eventually having logic like:

if vals[i][j][k] == 1
  (draw a cube here)

after this the logic for the rest of the script should work.

But from what I currently have I'm not getting anything... no bugs, no text, nothing.
I assume I have some text misplaced but I'm not sure where.. I'm kind of new to python.

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5846

Latest Images

Trending Articles



Latest Images