<?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: Set street width based on (non numeric) object attribute in ArcGIS CityEngine Questions</title>
    <link>https://community.esri.com/t5/arcgis-cityengine-questions/set-street-width-based-on-non-numeric-object/m-p/259724#M3418</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi !&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Street graphs create blocks, blocks create street and lot shapes, with respective attribution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;CGA ALWAYS starts with a shape and it's attributes &amp;gt; CGA can not alter street graphs or blocks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thus, what you need is to set up the system so that the streets inherit attributes down to the shapes, for use in CGA. ( I know, this may sound a bit abstract at first, before playing around with it. )&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;An other thing you can in CGA is to check the 'width' of a street shape based on the actual dimension with checking&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;geometry.du / .dv&lt;/STRONG&gt;&lt;SPAN&gt;, a specific CGA function that gives back the length and width of the geometry of a shape.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Otherwise, Python can be used to get and set attributes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;E.g. if a street segment is wider than 20 meters, set the street shapes' attribute 'street type' to 'hugeFrigginBoulevard', ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There's many options to reach what you need.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matt&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 06 Feb 2014 17:20:58 GMT</pubDate>
    <dc:creator>MatthiasBuehler1</dc:creator>
    <dc:date>2014-02-06T17:20:58Z</dc:date>
    <item>
      <title>Set street width based on (non numeric) object attribute</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/set-street-width-based-on-non-numeric-object/m-p/259723#M3417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi folks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I understand that the streetWidth shape parameter is generated when the shape is created. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But is there no way to change it dynamically through CGA coding?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd like to set it based on the type of road, as specified in the original network data attribute table; ie 'arterials' would set street width to 20m, 'collectors' to 16 m, etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Tom&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Feb 2014 21:23:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/set-street-width-based-on-non-numeric-object/m-p/259723#M3417</guid>
      <dc:creator>Tom-PierreFrappé-Sénéclauze</dc:creator>
      <dc:date>2014-02-05T21:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: Set street width based on (non numeric) object attribute</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/set-street-width-based-on-non-numeric-object/m-p/259724#M3418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi !&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Street graphs create blocks, blocks create street and lot shapes, with respective attribution.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;CGA ALWAYS starts with a shape and it's attributes &amp;gt; CGA can not alter street graphs or blocks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thus, what you need is to set up the system so that the streets inherit attributes down to the shapes, for use in CGA. ( I know, this may sound a bit abstract at first, before playing around with it. )&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;An other thing you can in CGA is to check the 'width' of a street shape based on the actual dimension with checking&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;geometry.du / .dv&lt;/STRONG&gt;&lt;SPAN&gt;, a specific CGA function that gives back the length and width of the geometry of a shape.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Otherwise, Python can be used to get and set attributes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;E.g. if a street segment is wider than 20 meters, set the street shapes' attribute 'street type' to 'hugeFrigginBoulevard', ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There's many options to reach what you need.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matt&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Feb 2014 17:20:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/set-street-width-based-on-non-numeric-object/m-p/259724#M3418</guid>
      <dc:creator>MatthiasBuehler1</dc:creator>
      <dc:date>2014-02-06T17:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Set street width based on (non numeric) object attribute</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/set-street-width-based-on-non-numeric-object/m-p/259725#M3419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Matthias,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have been experimenting with setting the street width based on layer attributes like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;width&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = getObjectAttr("StreetType", false)

streetWidthDefault = 7

attr streetWidth =
&amp;nbsp;&amp;nbsp;&amp;nbsp; case width == "Alley" : 4&amp;nbsp;&amp;nbsp;&amp;nbsp; * streetscale
&amp;nbsp;&amp;nbsp;&amp;nbsp; case width == "Arterial" : 12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * streetscale
&amp;nbsp;&amp;nbsp;&amp;nbsp; case width == "Collector" : 8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * streetscale 
&amp;nbsp;&amp;nbsp;&amp;nbsp; else&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : streetWidthDefault&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately, this same logic hasn't been working for sidewalk widths... any suggestions?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is part of my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;sidewalkr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = getObjectAttr("SidewalkR",false)

attr sidewalkWidthRight = 
&amp;nbsp;&amp;nbsp;&amp;nbsp; case sidewalkr == "Alley" : 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * streetscale
&amp;nbsp;&amp;nbsp;&amp;nbsp; case sidewalkr == "Arterial" : 6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * streetscale
&amp;nbsp;&amp;nbsp;&amp;nbsp; case sidewalkr == "Collector" : 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * streetscale 
&amp;nbsp;&amp;nbsp;&amp;nbsp; else&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : streetWidthDefault&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For some reason, it has been returning 0 for my sidewalkWidthRight.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:47:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/set-street-width-based-on-non-numeric-object/m-p/259725#M3419</guid>
      <dc:creator>NathanBrigmon</dc:creator>
      <dc:date>2021-12-11T12:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: Set street width based on (non numeric) object attribute</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/set-street-width-based-on-non-numeric-object/m-p/259726#M3420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but for the street widths it works ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;lemme know..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;m.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Mar 2014 12:00:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/set-street-width-based-on-non-numeric-object/m-p/259726#M3420</guid>
      <dc:creator>MatthiasBuehler1</dc:creator>
      <dc:date>2014-03-03T12:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: Set street width based on (non numeric) object attribute</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/set-street-width-based-on-non-numeric-object/m-p/259727#M3421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;but for the street widths it works ?&lt;BR /&gt;&lt;BR /&gt;lemme know..&lt;BR /&gt;&lt;BR /&gt;m.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, it was a strange thing, but I figured out the answer. Not sure why I had to take this route, but I needed to set the attribute source to "OBJECT", because it wasn't completely making the connection. So, I added a few extra lines of code as a fail-safe:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.setAttributeSource(streetsegment, "/ce/street/streetWidth", "OBJECT")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.setAttributeSource(streetsegment, "/ce/street/sidewalkWidthLeft ", "OBJECT")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.setAttributeSource(streetsegment, "/ce/street/sidewalkWidthRight", "OBJECT")

 &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've made a little progress in my python understanding and have changed my approach. After first selecting the objects from the scene with my specified attributes, I then run the above lines of code in a new context:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; selectedSegments = ce.getObjectsFrom(ce.selection())
&amp;nbsp;&amp;nbsp;&amp;nbsp; for streetsegment&amp;nbsp; in selectedSegments:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.setAttributeSource(streetsegment, "/ce/street/streetWidth", "OBJECT")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.setAttribute(streetsegment , 'streetWidth', W1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.setAttributeSource(streetsegment, "/ce/street/sidewalkWidthLeft", "OBJECT")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.setAttribute(streetsegment , 'sidewalkWidthLeft', W2)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.setAttributeSource(streetsegment, "/ce/street/sidewalkWidthRight", "OBJECT")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.setAttribute(streetsegment , '/sidewalkWidthRight', W3)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:47:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/set-street-width-based-on-non-numeric-object/m-p/259727#M3421</guid>
      <dc:creator>NathanBrigmon</dc:creator>
      <dc:date>2021-12-11T12:47:08Z</dc:date>
    </item>
  </channel>
</rss>

