<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Array sum of second column in ArcGIS CityEngine Questions</title>
    <link>https://community.esri.com/t5/arcgis-cityengine-questions/array-sum-of-second-column/m-p/1249825#M10841</link>
    <description>&lt;P&gt;Hi, I'm a bit confused here.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my CSV table I have a usage column and a floor height for that usage (just like the tutorial)&amp;nbsp;&lt;/P&gt;&lt;P&gt;Printing the usages&lt;BR /&gt;attr Testusages = [usages_data[0:numUsages-1,0],usages_data[0:numUsages-1,1]]&lt;/P&gt;&lt;P&gt;I receive:&lt;BR /&gt;(10x2)&lt;BR /&gt;Residential&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3,6576&lt;BR /&gt;Office&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3,9624&lt;BR /&gt;Business&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4,572&lt;BR /&gt;Parking&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3,048&lt;BR /&gt;Education&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3,9624&lt;BR /&gt;Sports&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7&lt;BR /&gt;Cultural&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4,572&lt;BR /&gt;Research&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3,048&lt;BR /&gt;Health&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4,572&lt;/P&gt;&lt;P&gt;The attribute:&lt;BR /&gt;@Enum(valuesAttr=Testusages)&lt;BR /&gt;attr floor_usages = stringArray()&lt;/P&gt;&lt;P&gt;is not showing the usage chosen + is height, it only shows the Usage. So if I print that one I get:&lt;BR /&gt;(10)[Residential,Parking,Residential,Residential,Residential,Sports,Residential,Residential,Business,Residential]&lt;/P&gt;&lt;P&gt;I want to calculate the sum of the height and pass it through as a value through my rule, depending on the floor usage chosen.&lt;/P&gt;&lt;P&gt;So if I could just pass the second row in the CSV, I would expect that I could do a sum() and then I would have the total height of the chosen usages.&lt;/P&gt;&lt;P&gt;But how to??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jan 2023 09:24:29 GMT</pubDate>
    <dc:creator>kelin84</dc:creator>
    <dc:date>2023-01-20T09:24:29Z</dc:date>
    <item>
      <title>Array sum of second column</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/array-sum-of-second-column/m-p/1249825#M10841</link>
      <description>&lt;P&gt;Hi, I'm a bit confused here.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my CSV table I have a usage column and a floor height for that usage (just like the tutorial)&amp;nbsp;&lt;/P&gt;&lt;P&gt;Printing the usages&lt;BR /&gt;attr Testusages = [usages_data[0:numUsages-1,0],usages_data[0:numUsages-1,1]]&lt;/P&gt;&lt;P&gt;I receive:&lt;BR /&gt;(10x2)&lt;BR /&gt;Residential&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3,6576&lt;BR /&gt;Office&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3,9624&lt;BR /&gt;Business&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4,572&lt;BR /&gt;Parking&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3,048&lt;BR /&gt;Education&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3,9624&lt;BR /&gt;Sports&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7&lt;BR /&gt;Cultural&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4,572&lt;BR /&gt;Research&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3,048&lt;BR /&gt;Health&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4,572&lt;/P&gt;&lt;P&gt;The attribute:&lt;BR /&gt;@Enum(valuesAttr=Testusages)&lt;BR /&gt;attr floor_usages = stringArray()&lt;/P&gt;&lt;P&gt;is not showing the usage chosen + is height, it only shows the Usage. So if I print that one I get:&lt;BR /&gt;(10)[Residential,Parking,Residential,Residential,Residential,Sports,Residential,Residential,Business,Residential]&lt;/P&gt;&lt;P&gt;I want to calculate the sum of the height and pass it through as a value through my rule, depending on the floor usage chosen.&lt;/P&gt;&lt;P&gt;So if I could just pass the second row in the CSV, I would expect that I could do a sum() and then I would have the total height of the chosen usages.&lt;/P&gt;&lt;P&gt;But how to??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 09:24:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/array-sum-of-second-column/m-p/1249825#M10841</guid>
      <dc:creator>kelin84</dc:creator>
      <dc:date>2023-01-20T09:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Array sum of second column</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/array-sum-of-second-column/m-p/1250349#M10843</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/418640"&gt;@kelin84&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Can't you just calculate the total height like this&lt;/P&gt;&lt;LI-CODE lang="python"&gt;const totalHeight = sum(floatArray(usages_data[0:numUsages-1,1]))&lt;/LI-CODE&gt;&lt;P&gt;and then make use of it whenever you need in your rule?&lt;/P&gt;&lt;P&gt;Cheers,&lt;BR /&gt;Jonas&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 13:16:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/array-sum-of-second-column/m-p/1250349#M10843</guid>
      <dc:creator>JonasObertuefer</dc:creator>
      <dc:date>2023-01-23T13:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: Array sum of second column</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/array-sum-of-second-column/m-p/1250366#M10844</link>
      <description>&lt;P&gt;Thank you Jonas, as far as I understand this will give the total of the array, and not the total of the chosen usages.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where I don't find any issues in showing only the chosen usage types in a filtered array, since that is done by the attribute selection:&lt;/P&gt;&lt;P&gt;So I want the same functionality as the floor usages:&lt;BR /&gt;(4)[Residential,Residential,Residential,Business]&lt;/P&gt;&lt;P&gt;just with the floor height, without choosing it as an attribute.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;case floor_usages == "Residential" : 3,5

case floor_usages == "business" : 5

(4)[Residential,Residential,Residential,Business]

(4)[3.5,3.5,3.5,5]

buildingHeight == 15,5&lt;/LI-CODE&gt;&lt;P&gt;If that make sense?&lt;/P&gt;&lt;P&gt;Right now I'm getting a stringArray of the of the selected floor usages. The attributes that I'm able to choose is from the CSV, and is filtered to only show the usages.&lt;/P&gt;&lt;P&gt;This attribute writes both usages and floor height of the full CSV&lt;/P&gt;&lt;LI-CODE lang="python"&gt;attr Testusages = [usages_data[0:numUsages-1,0],usages_data[0:numUsages-1,1]]&lt;/LI-CODE&gt;&lt;LI-CODE lang="c"&gt;(9x2)
   Residential   3,6576
        Office   3,9624
      Business    4,572
       Parking    3,048
     Education   3,9624
        Sports        7
      Cultural    4,572
      Research    3,048
        Health    4,572&lt;/LI-CODE&gt;&lt;P&gt;but the attrubute for choosing usages are only passing through the first column:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;@Enum(valuesAttr=Testusages)
attr floor_usages = stringArray()&lt;/LI-CODE&gt;&lt;P&gt;=&lt;/P&gt;&lt;LI-CODE lang="c"&gt;(5)[Residential,Residential,Residential,Business,Residential]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My idea was to add&lt;/P&gt;&lt;P&gt;take the array it creates and filter on the second column&lt;/P&gt;&lt;P&gt;like:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;print(sum(floor_usages[0:numUsages-1,1]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 14:16:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/array-sum-of-second-column/m-p/1250366#M10844</guid>
      <dc:creator>kelin84</dc:creator>
      <dc:date>2023-01-23T14:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: Array sum of second column</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/array-sum-of-second-column/m-p/1250680#M10846</link>
      <description>&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;So you want to choose by usage height and not by usage type in the inspector? Or do you just want to know the final height of the building?&lt;/P&gt;&lt;P&gt;For the later I would use report:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// edited Assign_Floor_Usages_03.cga

FloorMass(floorInd) --&amp;gt;
	Reports(floor_usages[floorInd], getUsageColor(floor_usages[floorInd]), getFloorHeight(floor_usages[floorInd]))
	extrude(getFloorHeight(floor_usages[floorInd]))
	color(getUsageColor(floor_usages[floorInd]))
	s('1, '0.95, '1)
	FloorMass.
	
Reports(myUsage, myUsageColor, myFloorHeight) --&amp;gt;
	report("GFA." + myUsage, geometry.area)
	report("GFA." + myUsage + "#color", myUsageColor)
	report("Building Height", myFloorHeight)
	NIL&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2023 07:28:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/array-sum-of-second-column/m-p/1250680#M10846</guid>
      <dc:creator>JonasObertuefer</dc:creator>
      <dc:date>2023-01-24T07:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Array sum of second column</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/array-sum-of-second-column/m-p/1251516#M10849</link>
      <description>&lt;P&gt;Thank you again Jonas for your answers, that is much appreciated. I realized that I couldn't explain my thoughts. I started to write a response to your last post, but it was messy writing.&lt;/P&gt;&lt;P&gt;The basic is that I wanted to use the floors_usages as a ratio and not a per floor kind of thing. If the building percentage allowed med to create 10 floors, I would use that as an input, and the 2 usage types for example, those would both have 5 floors each. That would have been easy, if it wasn't because the different usages had different heights. I was for sure going in the wrong direction, so it wasn't as complicated as I made it out to be:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;buildingFootprint(buildingarea,lotArea) --&amp;gt;
	createFloors(rint(transect*lotArea/buildingarea))

createFloors(floorCount) --&amp;gt;

Recs(rint(floorCount/size(floor_usages)),0,size(floor_usages))

Recs(noFloors,arrayIdx,arraySize) --&amp;gt;
case arrayIdx == arraySize : NIL
else :
	extrude(getFloorHeight(floor_usages[arrayIdx])*noFloors)
		comp(f) {top : Recs(noFloors,arrayIdx+1,arraySize) | side : Something(noFloors,arrayIdx,arraySize)}
	

Something(noFloors,arrayIdx,arraySize) --&amp;gt;
split(y) {getFloorHeight(floor_usages[arrayIdx]) :
color(getUsageColor(floor_usages[arrayIdx])) X.}* &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;So this is solved, but will still look at making it a bit more optimized.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2023 19:13:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/array-sum-of-second-column/m-p/1251516#M10849</guid>
      <dc:creator>kelin84</dc:creator>
      <dc:date>2023-01-25T19:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: Array sum of second column</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/array-sum-of-second-column/m-p/1252771#M10855</link>
      <description>&lt;P&gt;Glad you make it work and cool to see your adaption of the csv example &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Just from a quick look at your snippet: You might can get rid of Recs() and do everything in createFloors(). In general if you do more complex calculations which you might use multiple times consider writing it as a &lt;A href="https://doc.arcgis.com/en/cityengine/latest/help/help-rules-functions.htm" target="_self"&gt;function&lt;/A&gt; .&lt;/P&gt;&lt;P&gt;I marked your post as a solution.&lt;/P&gt;&lt;P&gt;Best,&lt;BR /&gt;Jonas&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 07:32:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/array-sum-of-second-column/m-p/1252771#M10855</guid>
      <dc:creator>JonasObertuefer</dc:creator>
      <dc:date>2023-01-30T07:32:30Z</dc:date>
    </item>
  </channel>
</rss>

