Split into grid and select cell

422
1
11-04-2022 01:23 PM
DKossowsky
New Contributor

I'm trying to split a shape into a grid and I want to be able to access an index of values for the grid cells. For example, if I have a 5x5 grid, I want to be able to access value 1,1 (row 1, column 1), and 1,2 (row 1, column 2) from within the rule. Or, I want to be able to assign unique values to each square, (e.g. 1 - 25 in a 5x5 grid).

Currently, when I create a grid and I use split.index = 1, it selects an entire row rather than just 1 grid square.

Any help would be appreciated. Thanks.

0 Kudos
1 Reply
desert
by
New Contributor III

I tried the following

 

@hidden
attr id = 0

@Group("split",0)
attr split_column = 2
@Group("split",0)
attr split_row = 2

@Group("select",1)
attr column_selected = 1
@Group("select",1)
attr row_selected = 1

Lot --> 
	split(x){'(1/ split_column ) : A(split.index)}*

A(col_num) --> 
	split(z){'(1/ split_row 😞 B(col_num, split.index)}*

B(col_num, row_num) -->
	comp(f){all : set(id, col_num*split.total+row_num) D(col_num, row_num)}
	

D(col_num, row_num)-->
	case col_num+1 == column_selected && row_num+1 == row_selected :
		color(1,0,0) X.
	else : X.

The ID value can be viewed in the inspector panel after selecting a face in the MODEL HIERARCHY panel.

Hope this helps.

 

 

 

 

0 Kudos