<?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 Re: Using comp and listAdd to gather shape geometry in ArcGIS CityEngine Questions</title>
    <link>https://community.esri.com/t5/arcgis-cityengine-questions/using-comp-and-listadd-to-gather-shape-geometry/m-p/36464#M503</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In 2019.0, the new&amp;nbsp;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;comp&lt;/SPAN&gt;&amp;nbsp;function (the existing &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;comp&lt;/SPAN&gt; operation co-exists with the new &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;comp&lt;/SPAN&gt; function) allows you to access attributes for each edge by returning an array, with one element per edge.&amp;nbsp; You can use &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;comp&lt;/SPAN&gt; to get an array of edge lengths.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;getEdgeLengths = comp(fe) { all: scope.sx }

Lot --&amp;gt;
	print(getEdgeLengths)
	print(size(getEdgeLengths))				// size of array
	print(getEdgeLengths[0])				// element at index 0
	print(index(getEdgeLengths, 10, 0.1))	// index of first occurrence of value=10 with eps=0.1
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;A href="https://doc.arcgis.com/en/cityengine/latest/cga/cga-comp-function.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;https://doc.arcgis.com/en/cityengine/latest/cga/cga-comp-function.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are the help pages to get array info like &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;size&lt;/SPAN&gt;, &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;item&lt;/SPAN&gt;, &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;index&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;&lt;A href="https://doc.arcgis.com/en/cityengine/latest/cga/cga-size-function.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;https://doc.arcgis.com/en/cityengine/latest/cga/cga-size-function.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://doc.arcgis.com/en/cityengine/latest/cga/cga-item-operator-function.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;https://doc.arcgis.com/en/cityengine/latest/cga/cga-item-operator-function.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://doc.arcgis.com/en/cityengine/latest/cga/cga-index-function.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;https://doc.arcgis.com/en/cityengine/latest/cga/cga-index-function.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For more examples, check out how &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;comp&lt;/SPAN&gt; is used to when definining &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;dists&lt;/SPAN&gt; in the examples on the help page for the &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;setback&lt;/SPAN&gt; operation.&lt;/P&gt;&lt;P&gt;&lt;A href="https://doc.arcgis.com/en/cityengine/latest/cga/cga-setback.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;https://doc.arcgis.com/en/cityengine/latest/cga/cga-setback.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your above approach doesn't work because shapes created from a comp do not know about each other.&amp;nbsp;&amp;nbsp;Let's say you have 4 edges.&amp;nbsp; The comp will create 4 different shapes in the shape tree, one for each edge, and these shapes do not know about each other.&amp;nbsp; The code in the Edges rule is run 4 times, once for each edge, but these are run independently of each other; they do not build on each other sequentially.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 21:24:38 GMT</pubDate>
    <dc:creator>CherylLau</dc:creator>
    <dc:date>2021-12-10T21:24:38Z</dc:date>
    <item>
      <title>Using comp and listAdd to gather shape geometry</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/using-comp-and-listadd-to-gather-shape-geometry/m-p/36463#M502</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd like to use listAdd to create a string that contains geometry information about shapes generated through the comp operation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code below separates the shape into its edge components and, in the Edges rule, tries to gather the edge lengths recursively and store them in the EdgeLengths attribute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rather than storing separate edge lengths, it produces a string with the same edge length listed multiple times, i.e., the loop is running multiple times on the same edge shape.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is using listAdd in this way possible in CGA, or is there another way to accomplish this? Is this something I'd need Python integration for?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm new to CGA, so any guidance is helpful!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;/**&lt;BR /&gt; * File: listfunctions.cga&lt;BR /&gt; * Created: 16 Jan 2019 20:40:45 GMT&lt;BR /&gt; * Author: chlvws&lt;BR /&gt; */&lt;/P&gt;&lt;P&gt;version "2018.0"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;attr EdgeLengths = ""&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Rules&lt;BR /&gt;@StartRule&lt;BR /&gt;&lt;STRONG&gt;Lot--&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;comp(e) { all : Edges }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Edges--&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;case listSize(EdgeLengths) &amp;lt; 3:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set(EdgeLengths, AddItem(str(scope.sx)))&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Edges&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;else: print(EdgeLengths)&lt;BR /&gt; &lt;BR /&gt;#Functions&lt;BR /&gt;&lt;STRONG&gt;AddItem(Edge) =&lt;/STRONG&gt;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;listAdd(EdgeLengths, Edge)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jan 2019 18:01:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/using-comp-and-listadd-to-gather-shape-geometry/m-p/36463#M502</guid>
      <dc:creator>MatthewPleasant</dc:creator>
      <dc:date>2019-01-23T18:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using comp and listAdd to gather shape geometry</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/using-comp-and-listadd-to-gather-shape-geometry/m-p/36464#M503</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In 2019.0, the new&amp;nbsp;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;comp&lt;/SPAN&gt;&amp;nbsp;function (the existing &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;comp&lt;/SPAN&gt; operation co-exists with the new &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;comp&lt;/SPAN&gt; function) allows you to access attributes for each edge by returning an array, with one element per edge.&amp;nbsp; You can use &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;comp&lt;/SPAN&gt; to get an array of edge lengths.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;getEdgeLengths = comp(fe) { all: scope.sx }

Lot --&amp;gt;
	print(getEdgeLengths)
	print(size(getEdgeLengths))				// size of array
	print(getEdgeLengths[0])				// element at index 0
	print(index(getEdgeLengths, 10, 0.1))	// index of first occurrence of value=10 with eps=0.1
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;A href="https://doc.arcgis.com/en/cityengine/latest/cga/cga-comp-function.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;https://doc.arcgis.com/en/cityengine/latest/cga/cga-comp-function.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are the help pages to get array info like &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;size&lt;/SPAN&gt;, &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;item&lt;/SPAN&gt;, &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;index&lt;/SPAN&gt;:&lt;/P&gt;&lt;P&gt;&lt;A href="https://doc.arcgis.com/en/cityengine/latest/cga/cga-size-function.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;https://doc.arcgis.com/en/cityengine/latest/cga/cga-size-function.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://doc.arcgis.com/en/cityengine/latest/cga/cga-item-operator-function.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;https://doc.arcgis.com/en/cityengine/latest/cga/cga-item-operator-function.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://doc.arcgis.com/en/cityengine/latest/cga/cga-index-function.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;https://doc.arcgis.com/en/cityengine/latest/cga/cga-index-function.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For more examples, check out how &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;comp&lt;/SPAN&gt; is used to when definining &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;dists&lt;/SPAN&gt; in the examples on the help page for the &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;setback&lt;/SPAN&gt; operation.&lt;/P&gt;&lt;P&gt;&lt;A href="https://doc.arcgis.com/en/cityengine/latest/cga/cga-setback.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;https://doc.arcgis.com/en/cityengine/latest/cga/cga-setback.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your above approach doesn't work because shapes created from a comp do not know about each other.&amp;nbsp;&amp;nbsp;Let's say you have 4 edges.&amp;nbsp; The comp will create 4 different shapes in the shape tree, one for each edge, and these shapes do not know about each other.&amp;nbsp; The code in the Edges rule is run 4 times, once for each edge, but these are run independently of each other; they do not build on each other sequentially.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:24:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/using-comp-and-listadd-to-gather-shape-geometry/m-p/36464#M503</guid>
      <dc:creator>CherylLau</dc:creator>
      <dc:date>2021-12-10T21:24:38Z</dc:date>
    </item>
  </channel>
</rss>

