Select to view content in your preferred language

Finding the sum of split.index

188
3
Jump to solution
04-05-2025 10:44 AM
maziaryousefi
Emerging Contributor

Hello everyone. Is there a way to get the sum of the numbers generated by the division command using split.index? For example, we have a 5-story building and if we use the split.index command, the floors start from zero and finally the 5th floor receives the number 4 and the sum is 10, that is, 0+1+2+3+4 = 10

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
desert
by
Occasional Contributor

I'm curious whether your goal is simply to compute the sum of split.index values,
or if you also want to pass that sum into other rules for further use.

If your goal is just to calculate the sum, you can use the formula  "(split.total - 1) * split.total / 2"

If you'd like to pass the calculated value to other rules and use it there, you can write it like this:

attr unitHeight = 2   // Height of each split section

@StartRule
Lot -->
    extrude(10)  // Give height to the lot
    split(y){ ~unitHeight : Section }*  // Split along Y into equal parts


// Use 'with' to define sum_n as the sum of split.index values
Section 
    with ( sum_n := (split.total - 1) * split.total / 2 ) 
-->
    case split.index == 0 :
        Something_A(sum_n)
    ..
    ...
    ....
    else :
        Something_Else(sum_n)

 There may be various ways to approach this, so please take this as a reference only.

View solution in original post

0 Kudos
3 Replies
JonasObertuefer
Esri Contributor

Hi @maziaryousefi,

I believe split.total shape attribute is what you are looking for. Let's say you split your mass into three pieces, then split.index is 0,1,2 and split.total is 3.

See also split shape attribute  in the CGA reference.

Cheers
Jonas

 

 

0 Kudos
desert
by
Occasional Contributor

I'm curious whether your goal is simply to compute the sum of split.index values,
or if you also want to pass that sum into other rules for further use.

If your goal is just to calculate the sum, you can use the formula  "(split.total - 1) * split.total / 2"

If you'd like to pass the calculated value to other rules and use it there, you can write it like this:

attr unitHeight = 2   // Height of each split section

@StartRule
Lot -->
    extrude(10)  // Give height to the lot
    split(y){ ~unitHeight : Section }*  // Split along Y into equal parts


// Use 'with' to define sum_n as the sum of split.index values
Section 
    with ( sum_n := (split.total - 1) * split.total / 2 ) 
-->
    case split.index == 0 :
        Something_A(sum_n)
    ..
    ...
    ....
    else :
        Something_Else(sum_n)

 There may be various ways to approach this, so please take this as a reference only.

0 Kudos
maziaryousefi
Emerging Contributor

Thanks for your answer - I want to get the total electricity consumption of the floors and then display it in the report panel at the top of the building. I used the same method as you but it gives the wrong result. I think I need to find a way to associate the amount of electricity consumed by each floor with numerical indices split.index via the set command. If you have any ideas on this, I would be happy to hear it.

 

maziaryousefi_0-1744226301870.jpeg

maziaryousefi_0-1744308868137.png

 

 

 

 

 

0 Kudos