CGA for Add Array

645
2
Jump to solution
01-04-2023 11:46 PM
SangmukKyleSeok
New Contributor
 
 
Hi folks, 
 
I have a Rule that repeats multiple times, and I want to use that rule's number of iteration for another Rule as a dynamic parameter. It is possible to check the number of iterations using the 'report operation' - [SUM], but as far as I know it is impossible to use this number as a parameter.
 
So, whenever the rule is repeated, I tried to save index in the array and use size of the array as a number of iterations, but I couldn't find a way to add a new value to the already created array.
 
i.e. When the number of iterations of the rule is N, sequentially changing the array like [1], [1;2], [1;2;3],...[1;...;N]
 
Can someone help me ?
 
Thank you for always.
 
Kyle,
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
ThomasFuchs
Esri Regular Contributor

Thank you @SangmukKyleSeok  for your question. 
New values can be appended to arrays with this notation:

Generate --> Iterate([0, 1])

Iterate(c)-->
	case size(c) >= 10: print(c)
	else: Iterate([c, size(c)+1])


Please have a look at the example in the CGA help:
array initialization function—ArcGIS CityEngine Resources | Documentation

View solution in original post

2 Replies
ThomasFuchs
Esri Regular Contributor

Thank you @SangmukKyleSeok  for your question. 
New values can be appended to arrays with this notation:

Generate --> Iterate([0, 1])

Iterate(c)-->
	case size(c) >= 10: print(c)
	else: Iterate([c, size(c)+1])


Please have a look at the example in the CGA help:
array initialization function—ArcGIS CityEngine Resources | Documentation

KyleSeok
New Contributor III

An unexpected approach!

With your help, I was able to solve the problem using arrays.

Thank you! 

 

Kyle

0 Kudos