<?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: How do I access user specified attributes, via python? in ArcGIS CityEngine Questions</title>
    <link>https://community.esri.com/t5/arcgis-cityengine-questions/how-do-i-access-user-specified-attributes-via/m-p/249640#M3315</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is this still the case in CityEngine 2012.1?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to something similar, I have this CGA rule applied to a shape:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
version "2012.1"

attr MyAttribute&amp;nbsp;&amp;nbsp;&amp;nbsp; = true

Lot --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; BuildingMass

LotInner --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; BuildingMass

BuildingMass --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; extrude(20)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Building 

Building --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; set(MyAttribute, true)
&amp;nbsp;&amp;nbsp;&amp;nbsp; color(1,1,0)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then I have generated the shape.&amp;nbsp; I then have this python script to interrogate it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
from scripting import *

ce = CE()

def main():
&amp;nbsp;&amp;nbsp;&amp;nbsp; print
&amp;nbsp;&amp;nbsp;&amp;nbsp; shapes = ce.getObjectsFrom(ce.selection)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for shape in shapes:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print shape
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print ce.getAttributeList(shape)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print ce.getAttributeSource(shape, "/ce/rule/MyAttribute" )
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print ce.getAttribute(shape, "/ce/rule/MyAttribute" )
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; main()
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I select the generated object, I get this output:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Shape:MyBuilding.cga:Lot
[]
None
None
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I delete the generated object, and just select the lot shape, I get this output:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Shape
['/ce/name', '/ce/rule/randomSeed', '/ce/rule/ruleFile', '/ce/rule/startRule', '0streetWidth\x00', '1streetWidth\x00', '2streetWidth\x00', '3streetWidth\x00', '4streetWidth\x00', 'shapeType']
DEFAULT
None
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My questions is, within CE 2012.1, is there a way to mark certain geometry from CGA rules and access it from python?&amp;nbsp; My end goal is to mark certain geometry and then allow my python exporter to distinguish between the different geometries so it can export them into a different model file.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 12:24:42 GMT</pubDate>
    <dc:creator>PaulMacArthur</dc:creator>
    <dc:date>2021-12-11T12:24:42Z</dc:date>
    <item>
      <title>How do I access user specified attributes, via python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/how-do-i-access-user-specified-attributes-via/m-p/249638#M3313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have added a 'userModel' attribute to my basic instance placement.cga file&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have selected and generated buildings on my lots &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;They all contain placed 'instances'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have selected a random lot and want to check what it is via python?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;print ce.getAttribute(ce.selection()[0], '/ce/rule/userModel')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I get None returned, yet I can clearly see I have model instance placed in the Inspector.. and I can see the project path to it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are user Attributes not accessible in this manner?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Mar 2012 00:58:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/how-do-i-access-user-specified-attributes-via/m-p/249638#M3313</guid>
      <dc:creator>RobertHexter</dc:creator>
      <dc:date>2012-03-05T00:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do I access user specified attributes, via python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/how-do-i-access-user-specified-attributes-via/m-p/249639#M3314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;print ce.getAttribute(ce.selection()[0], '/ce/rule/userModel')&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;This command returns the USER value of the rule attribute named userModel. (The user value is set when a rule attribute is manually set in the inspector, and is displayed bold)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It does not return the Rule value. (The rule value is suffixed with (Rule) in the Inspector.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rule values can not be queried with Python atm.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To figure out if a rule attribute is user-set, you can query its source&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ce.getAttributeSource(ce.selection()[0],"/ce/rule/userModel")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;DEFAULT -&amp;gt; value is set from rule&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;USER -&amp;gt; value is set by user&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;----------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Object Attributes (found the Object Atttributes pane of the Inspector) are queried without prefix:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print ce.getAttribute(ce.selection()[0], 'myObjectAttribute')&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Mar 2012 07:36:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/how-do-i-access-user-specified-attributes-via/m-p/249639#M3314</guid>
      <dc:creator>AndreasUlmer</dc:creator>
      <dc:date>2012-03-05T07:36:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I access user specified attributes, via python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/how-do-i-access-user-specified-attributes-via/m-p/249640#M3315</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is this still the case in CityEngine 2012.1?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to something similar, I have this CGA rule applied to a shape:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
version "2012.1"

attr MyAttribute&amp;nbsp;&amp;nbsp;&amp;nbsp; = true

Lot --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; BuildingMass

LotInner --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; BuildingMass

BuildingMass --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; extrude(20)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Building 

Building --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; set(MyAttribute, true)
&amp;nbsp;&amp;nbsp;&amp;nbsp; color(1,1,0)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then I have generated the shape.&amp;nbsp; I then have this python script to interrogate it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
from scripting import *

ce = CE()

def main():
&amp;nbsp;&amp;nbsp;&amp;nbsp; print
&amp;nbsp;&amp;nbsp;&amp;nbsp; shapes = ce.getObjectsFrom(ce.selection)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for shape in shapes:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print shape
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print ce.getAttributeList(shape)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print ce.getAttributeSource(shape, "/ce/rule/MyAttribute" )
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print ce.getAttribute(shape, "/ce/rule/MyAttribute" )
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; main()
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I select the generated object, I get this output:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Shape:MyBuilding.cga:Lot
[]
None
None
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I delete the generated object, and just select the lot shape, I get this output:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
Shape
['/ce/name', '/ce/rule/randomSeed', '/ce/rule/ruleFile', '/ce/rule/startRule', '0streetWidth\x00', '1streetWidth\x00', '2streetWidth\x00', '3streetWidth\x00', '4streetWidth\x00', 'shapeType']
DEFAULT
None
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My questions is, within CE 2012.1, is there a way to mark certain geometry from CGA rules and access it from python?&amp;nbsp; My end goal is to mark certain geometry and then allow my python exporter to distinguish between the different geometries so it can export them into a different model file.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:24:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/how-do-i-access-user-specified-attributes-via/m-p/249640#M3315</guid>
      <dc:creator>PaulMacArthur</dc:creator>
      <dc:date>2021-12-11T12:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I access user specified attributes, via python?</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/how-do-i-access-user-specified-attributes-via/m-p/249641#M3316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is something that you would do via the reporting mechanism.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Then use python to process the reported data.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Dec 2012 22:46:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/how-do-i-access-user-specified-attributes-via/m-p/249641#M3316</guid>
      <dc:creator>RobertHexter</dc:creator>
      <dc:date>2012-12-13T22:46:45Z</dc:date>
    </item>
  </channel>
</rss>

