<?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 Python to create an object attribute from a rule attribute in ArcGIS CityEngine Questions</title>
    <link>https://community.esri.com/t5/arcgis-cityengine-questions/using-python-to-create-an-object-attribute-from-a/m-p/539825#M7303</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Cheryl,&lt;/P&gt;&lt;P&gt;Thanks for your input on this thread already!&lt;/P&gt;&lt;P&gt;I've followed what I think is the approach outlined above, looking to embed multiple report values into Object Attributes. I'm not having any success - first time wrangling Python. My scripts look like this at present, both made via the Python template modules&amp;nbsp;- are you able to help?&lt;/P&gt;&lt;P&gt;Much appreciated,&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Main script:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'''&lt;/P&gt;&lt;P&gt;Created on 20/01/2020&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@author: Tim.Robinson&lt;/P&gt;&lt;P&gt;'''&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: small; "&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; scripting &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: small; "&gt;import&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# get list of selected shapes&lt;/P&gt;&lt;P&gt;shapeList = ce.getObjectsFrom(ce.selection, ce.isShape)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# run export script to get reported values and set obj attr&lt;/P&gt;&lt;P&gt;expSettings = ScriptExportModelSettings()&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt;expSettings.setScript(&lt;/SPAN&gt;&lt;EM&gt;&lt;SPAN style="color: #00aa00; font-size: small; "&gt;"&lt;/SPAN&gt;&lt;SPAN style="text-decoration: underline; font-size: small; "&gt;GISexportScript&lt;/SPAN&gt;&lt;SPAN style="color: #00aa00; font-size: small; "&gt;.py"&lt;/SPAN&gt;&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ce.export(shapeList, expSettings)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Export script (GISexportScript.py):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'''&lt;/P&gt;&lt;P&gt;Created on 20/01/2020&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@author: Tim.Robinson&lt;/P&gt;&lt;P&gt;'''&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: small; "&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; scripting &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: small; "&gt;import&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Get a CityEngine instance&lt;/P&gt;&lt;P&gt;ce = CE()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Called before the export start.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: small; "&gt;def&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; &lt;STRONG&gt;initExport&lt;/STRONG&gt;(exportContextOID):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ctx = ScriptExportModelSettings(exportContextOID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Called for each shape before generation.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: small; "&gt;def&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; &lt;STRONG&gt;initModel&lt;/STRONG&gt;(exportContextOID, shapeOID):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ctx = ScriptExportModelSettings(exportContextOID)&lt;/P&gt;&lt;P&gt;shape = Shape(shapeOID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Called for each shape after generation.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: small; "&gt;def&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; &lt;STRONG&gt;finishModel&lt;/STRONG&gt;(exportContextOID, shapeOID, modelOID):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ctx = ScriptExportModelSettings(exportContextOID)&lt;/P&gt;&lt;P&gt;shape = Shape(shapeOID)&lt;/P&gt;&lt;P&gt;model = Model(modelOID)&lt;/P&gt;&lt;P&gt;# get reported value for New Dwellings.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; r = model.getReports()[&lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"X_Dwellings@Av"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;][&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: small; "&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# set object attr to reported New Dwellings.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; ce.setAttribute(shape, &lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"X_Dwellings@Av"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;, r) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# get reported value for GFA GF.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; r = model.getReports()[&lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"GFA.GF"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;][&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: small; "&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# set object attr to reported GFA GF.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; ce.setAttribute(shape, &lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"GFA.GF"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;, r) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# get reported value for GFA Resi.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; r = model.getReports()[&lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"GFA.Resi"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;][&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: small; "&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# set object attr to reported GFA Resi.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; ce.setAttribute(shape, &lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"GFA.Resi"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;, r) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# get reported value for GFA Comm.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; r = model.getReports()[&lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"GFA.Comm"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;][&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: small; "&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# set object attr to reported GFA Comm.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; ce.setAttribute(shape, &lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"GFA.Comm"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;, r) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# get reported value for GFA Retained.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; r = model.getReports()[&lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"GFAExtgGIS_Retained"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;][&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: small; "&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# set object attr to reported GFA Retained.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; ce.setAttribute(shape, &lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"GFAExtgGIS_Retained"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;, r) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Called after all shapes are generated.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: small; "&gt;def&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; &lt;STRONG&gt;finishExport&lt;/STRONG&gt;(exportContextOID):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ctx = ScriptExportModelSettings(exportContextOID)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Jan 2020 21:38:23 GMT</pubDate>
    <dc:creator>timrobinson</dc:creator>
    <dc:date>2020-01-20T21:38:23Z</dc:date>
    <item>
      <title>Using Python to create an object attribute from a rule attribute</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/using-python-to-create-an-object-attribute-from-a/m-p/539821#M7299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to write a python script that will create a new object attribute containing the parcel area for any number of parcels I’ve selected in the scene. I know I need to use Export (Reporting) python script to fetch the value of a rule attribute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proposed method:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Select the desired parcels in the scene&lt;/LI&gt;&lt;LI&gt;Run a python script that assigns the CGA rule “calculateParcelArea.cga” to each of the parcels, generates the models using “calculateParcelArea.cga”, and reports the area in the Parcel_Area row, under the sum column.&lt;/LI&gt;&lt;LI&gt;The python script then fetches the reports for each of the parcels, creates a new object attribute named ‘parcelArea’ for each parcel, and assigns the reported value.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So far I’ve written a regular python (Module: Main) script that assigns the “calculateParcelArea.cga” to the selected parcels, generates the models with areas saved to rule attribute ‘parcelArea_Calc’, and reports the value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I’m having difficulty with the Export (Reporting) python module. Can someone help me make sense of this? How do I bring the existing script into the Export (Reporting) python module to complete the task? &amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Python script and CGA rule below:&lt;/P&gt;&lt;P&gt;_____________________________________________________________________________________&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;EM style="color: #00aa00; font-size: 10.0pt;"&gt;'''&lt;/EM&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;EM style="color: #00aa00; font-size: 10.0pt;"&gt;Created on 2017-07-26&lt;/EM&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;EM style="color: #00aa00; font-size: 10.0pt;"&gt;@author: bcbd&lt;/EM&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;EM style="color: #00aa00; font-size: 10.0pt;"&gt;'''&lt;/EM&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: blue;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; scripting &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: blue;"&gt;import&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; *&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: silver;"&gt;# get a CityEngine instance&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;ce = CE()&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: blue;"&gt;def&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; &lt;STRONG&gt;parcelArea&lt;/STRONG&gt;():&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; shapes = ce.getObjectsFrom(ce.selection, ce.isShape)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: blue;"&gt;for&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; shape &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: blue;"&gt;in&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; shapes:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.setRuleFile(ce.selection(), &lt;/SPAN&gt;&lt;EM style="color: #00aa00; font-size: 10.0pt;"&gt;'calculateParcelArea.cga'&lt;/EM&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;) &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm .0001pt 36.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: silver;"&gt;# assign CGA rule calcParcelArea&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.setStartRule(ce.selection(), &lt;/SPAN&gt;&lt;EM style="color: #00aa00; font-size: 10.0pt;"&gt;'Lot'&lt;/EM&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.generateModels(ce.selection())&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: blue;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; __name__ == &lt;/SPAN&gt;&lt;EM style="color: #00aa00; font-size: 10.0pt;"&gt;'__main__'&lt;/EM&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; parcelArea()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: blue;"&gt;pass&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;_____________________________________________________________________________________&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; text-indent: 36.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #3f5fc0;"&gt;/**&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt; text-indent: 36.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #3f5fc0;"&gt;&amp;nbsp;* File:&amp;nbsp;&amp;nbsp;&amp;nbsp; calculateParcelArea.cga&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: #3f5fc0;"&gt;&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;*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: #3f5fc0;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #7f0055; font-size: 10.0pt;"&gt;version&lt;/STRONG&gt; &lt;EM style="color: #0000c0; font-size: 10.0pt;"&gt;“2017.0”&lt;/EM&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm .0001pt 36.0pt;"&gt;&lt;STRONG style="color: #7f0055; font-size: 10.0pt;"&gt;attr&lt;/STRONG&gt; &lt;EM style="color: #0000c0; font-size: 10.0pt;"&gt;parcelArea_Calc&lt;/EM&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; = &lt;/SPAN&gt;&lt;STRONG style="color: #0000c0; font-size: 10.0pt;"&gt;geometry.area&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm .0001pt 36.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm .0001pt 36.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #600060;"&gt;Lot&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; --&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm .0001pt 36.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #600060;"&gt;report&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #2a00ff;"&gt;"Parcel_Area"&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;, &lt;/SPAN&gt;&lt;EM style="color: #0000c0; font-size: 10.0pt;"&gt;parcelArea_Calc&lt;/EM&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 36.0pt; text-indent: 36.0pt;"&gt;&lt;STRONG style="color: #0000c0; font-size: 10.0pt;"&gt;print&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: #2a00ff;"&gt;"Parcel_Area: "&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt; + &lt;/SPAN&gt;&lt;EM style="color: #0000c0; font-size: 10.0pt;"&gt;parcelArea_Calc&lt;/EM&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;_____________________________________________________________________________________&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Jul 2017 19:18:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/using-python-to-create-an-object-attribute-from-a/m-p/539821#M7299</guid>
      <dc:creator>BrendanBuchanan_Dee</dc:creator>
      <dc:date>2017-07-27T19:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to create an object attribute from a rule attribute</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/using-python-to-create-an-object-attribute-from-a/m-p/539822#M7300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think you want to try to get the rule attribute. &amp;nbsp;In Python, you could either get the initial value set in the cga file for this attribute or the user set value (e.g. if you want to get the value the user sets in the Inspector), but you don't want either of these values, and instead you want a value that is calculated within a rule. &amp;nbsp;Therefore, I think you want to get the reported value for the parcel area.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For each parcel shape, you can get the reported value for parcel area and then assign this to an object attribute of the parcel shape. &amp;nbsp;To do this, create a Python Main script and a Python Export script (right click on scripts -&amp;gt; New -&amp;gt; Python Module). &amp;nbsp;The following code assumes that a cga rule that reports the parcel area to "ParcelArea" has been applied to the selected parcel shapes. &amp;nbsp;The script reads the value for "ParcelArea" and sets an object attribute called "parcelArea" to have this value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your Python Main script, run the export script on your desired set of shapes.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # get list of selected shapes
&amp;nbsp;&amp;nbsp;&amp;nbsp; shapeList = ce.getObjectsFrom(ce.selection, ce.isShape)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # run export script to get reported values and set obj attr
&amp;nbsp;&amp;nbsp;&amp;nbsp; expSettings = ScriptExportModelSettings()
&amp;nbsp;&amp;nbsp;&amp;nbsp; expSettings.setScript("exportScript.py")
&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.export(shapeList, expSettings)
&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your Python Export script (called exportScript.py in above code), you only need to add two lines (8 and 11) to the end of the finishModel() method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;# Called for each shape after generation.
def finishModel(exportContextOID, shapeOID, modelOID):
&amp;nbsp;&amp;nbsp;&amp;nbsp; ctx = ScriptExportModelSettings(exportContextOID)
&amp;nbsp;&amp;nbsp;&amp;nbsp; shape = Shape(shapeOID)
&amp;nbsp;&amp;nbsp;&amp;nbsp; model = Model(modelOID)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # get reported value for ParcelArea
&amp;nbsp;&amp;nbsp;&amp;nbsp; r = model.getReports()["ParcelArea"][0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # set object attr to reported parcel area
&amp;nbsp;&amp;nbsp;&amp;nbsp; ce.setAttribute(shape, "parcelArea", r)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; # print to console
&amp;nbsp;&amp;nbsp;&amp;nbsp; print(str(shape) + ":&amp;nbsp; ParcelArea = " + str(r))
&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;/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;/P&gt;&lt;P&gt;Beware that if you change your parcel shapes (e.g. resize them), then the object attribute won't have the correct parcel area anymore, which also means that your buildings will not be receiving the correct parcel area, and you'll have to rerun the python script to update the object attribute.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:24:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/using-python-to-create-an-object-attribute-from-a/m-p/539822#M7300</guid>
      <dc:creator>CherylLau</dc:creator>
      <dc:date>2021-12-11T23:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to create an object attribute from a rule attribute</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/using-python-to-create-an-object-attribute-from-a/m-p/539823#M7301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear cheryl,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have read your tutorial carefully and try to export value from rule to object attribute but it can not. The value report is not exported to console.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/402351_error.png" style="width: 620px; height: 348px;" /&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;Warning&lt;BR /&gt;Thu Apr 19 02:29:34 ICT 2018&lt;BR /&gt;The batch export completed but at least one error occurred. See export logfile for detailed error information. - [main]&lt;/P&gt;&lt;P&gt;java.lang.Exception: Export script execution failed.&lt;BR /&gt; at com.esri.prt.export.ScriptModelExportContext$4.run(Unknown Source)&lt;BR /&gt; at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)&lt;BR /&gt;Caused by: Traceback (most recent call last):&lt;BR /&gt; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt; File "C:\Users\nguyenq\Documents\City engine\930\scripts\export.py", line 27, in finishModel&lt;BR /&gt; height = model.getReports()["Height"][0]&lt;BR /&gt;KeyError: Height&lt;/P&gt;&lt;P&gt;at org.python.core.Py.KeyError(Py.java:221)&lt;BR /&gt; at org.python.core.PyObject.__getitem__(PyObject.java:671)&lt;BR /&gt; at org.python.pycode._pyx687.finishModel$3(C:\Users\nguyenq\Documents\City engine\930\scripts\export.py:33)&lt;BR /&gt; at org.python.pycode._pyx687.call_function(C:\Users\nguyenq\Documents\City engine\930\scripts\export.py)&lt;BR /&gt; at org.python.core.PyTableCode.call(PyTableCode.java:165)&lt;BR /&gt; at org.python.core.PyBaseCode.call(PyBaseCode.java:166)&lt;BR /&gt; at org.python.core.PyFunction.__call__(PyFunction.java:368)&lt;BR /&gt; at org.python.pycode._pyx748.f$0(&amp;lt;string&amp;gt;:1)&lt;BR /&gt; at org.python.pycode._pyx748.call_function(&amp;lt;string&amp;gt;)&lt;BR /&gt; at org.python.core.PyTableCode.call(PyTableCode.java:165)&lt;BR /&gt; at org.python.core.PyCode.call(PyCode.java:18)&lt;BR /&gt; at org.python.core.Py.runCode(Py.java:1312)&lt;BR /&gt; at org.python.core.Py.exec(Py.java:1356)&lt;BR /&gt; at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:206)&lt;BR /&gt; at com.esri.prt.export.ScriptModelExportContext.finishModel(Unknown Source)&lt;BR /&gt; at com.esri.prt.export.ScriptModelExportContext.finishScriptExport(Unknown Source)&lt;BR /&gt; at com.esri.prt.export.ScriptModelExportContext.finishScriptExport(Unknown Source)&lt;BR /&gt; ... 2 more&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Can you explain to me what error happened here, although I have checked the object already has "Height" via inspector tool. Or can you guide me how to get value from rule-cga (not user defined)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2018 19:37:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/using-python-to-create-an-object-attribute-from-a/m-p/539823#M7301</guid>
      <dc:creator>NguyenLong</dc:creator>
      <dc:date>2018-04-18T19:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to create an object attribute from a rule attribute</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/using-python-to-create-an-object-attribute-from-a/m-p/539824#M7302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First, values need to be reported.&amp;nbsp; In my example above, the value for parcel area is reported in the CGA code.&amp;nbsp; The name of the report in "ParcelArea".&amp;nbsp; This value is visible in the Inspector under the Reports section.&amp;nbsp; Check that your reports are correct.&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;report("ParcelArea", geometry.area)&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second, the object attribute names are case sensitive.&amp;nbsp; The python code gets the reported value and then sets the object attribute called "parcelArea".&amp;nbsp; Object attributes can be seen in the Inspector under the Object Attributes section.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Third, object attributes are different from rule attributes.&amp;nbsp; In your screenshot, you circled the rule attributes in the Inspector, but the object attributes are being changed in the python code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2018 09:46:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/using-python-to-create-an-object-attribute-from-a/m-p/539824#M7302</guid>
      <dc:creator>CherylLau</dc:creator>
      <dc:date>2018-05-02T09:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to create an object attribute from a rule attribute</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/using-python-to-create-an-object-attribute-from-a/m-p/539825#M7303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Cheryl,&lt;/P&gt;&lt;P&gt;Thanks for your input on this thread already!&lt;/P&gt;&lt;P&gt;I've followed what I think is the approach outlined above, looking to embed multiple report values into Object Attributes. I'm not having any success - first time wrangling Python. My scripts look like this at present, both made via the Python template modules&amp;nbsp;- are you able to help?&lt;/P&gt;&lt;P&gt;Much appreciated,&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Main script:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'''&lt;/P&gt;&lt;P&gt;Created on 20/01/2020&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@author: Tim.Robinson&lt;/P&gt;&lt;P&gt;'''&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: small; "&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; scripting &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: small; "&gt;import&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# get list of selected shapes&lt;/P&gt;&lt;P&gt;shapeList = ce.getObjectsFrom(ce.selection, ce.isShape)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# run export script to get reported values and set obj attr&lt;/P&gt;&lt;P&gt;expSettings = ScriptExportModelSettings()&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt;expSettings.setScript(&lt;/SPAN&gt;&lt;EM&gt;&lt;SPAN style="color: #00aa00; font-size: small; "&gt;"&lt;/SPAN&gt;&lt;SPAN style="text-decoration: underline; font-size: small; "&gt;GISexportScript&lt;/SPAN&gt;&lt;SPAN style="color: #00aa00; font-size: small; "&gt;.py"&lt;/SPAN&gt;&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ce.export(shapeList, expSettings)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Export script (GISexportScript.py):&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'''&lt;/P&gt;&lt;P&gt;Created on 20/01/2020&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@author: Tim.Robinson&lt;/P&gt;&lt;P&gt;'''&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: small; "&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; scripting &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: small; "&gt;import&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; *&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Get a CityEngine instance&lt;/P&gt;&lt;P&gt;ce = CE()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Called before the export start.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: small; "&gt;def&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; &lt;STRONG&gt;initExport&lt;/STRONG&gt;(exportContextOID):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ctx = ScriptExportModelSettings(exportContextOID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Called for each shape before generation.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: small; "&gt;def&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; &lt;STRONG&gt;initModel&lt;/STRONG&gt;(exportContextOID, shapeOID):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ctx = ScriptExportModelSettings(exportContextOID)&lt;/P&gt;&lt;P&gt;shape = Shape(shapeOID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Called for each shape after generation.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: small; "&gt;def&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; &lt;STRONG&gt;finishModel&lt;/STRONG&gt;(exportContextOID, shapeOID, modelOID):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ctx = ScriptExportModelSettings(exportContextOID)&lt;/P&gt;&lt;P&gt;shape = Shape(shapeOID)&lt;/P&gt;&lt;P&gt;model = Model(modelOID)&lt;/P&gt;&lt;P&gt;# get reported value for New Dwellings.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; r = model.getReports()[&lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"X_Dwellings@Av"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;][&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: small; "&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# set object attr to reported New Dwellings.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; ce.setAttribute(shape, &lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"X_Dwellings@Av"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;, r) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# get reported value for GFA GF.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; r = model.getReports()[&lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"GFA.GF"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;][&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: small; "&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# set object attr to reported GFA GF.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; ce.setAttribute(shape, &lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"GFA.GF"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;, r) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# get reported value for GFA Resi.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; r = model.getReports()[&lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"GFA.Resi"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;][&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: small; "&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# set object attr to reported GFA Resi.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; ce.setAttribute(shape, &lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"GFA.Resi"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;, r) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# get reported value for GFA Comm.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; r = model.getReports()[&lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"GFA.Comm"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;][&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: small; "&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# set object attr to reported GFA Comm.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; ce.setAttribute(shape, &lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"GFA.Comm"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;, r) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# get reported value for GFA Retained.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; r = model.getReports()[&lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"GFAExtgGIS_Retained"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;][&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: small; "&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;# set object attr to reported GFA Retained.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small;"&gt; ce.setAttribute(shape, &lt;/SPAN&gt;&lt;EM style=": ; color: #00aa00; font-size: small; "&gt;"GFAExtgGIS_Retained"&lt;/EM&gt;&lt;SPAN style="font-size: small;"&gt;, r) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Called after all shapes are generated.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: small; "&gt;def&lt;/SPAN&gt;&lt;SPAN style="font-size: small;"&gt; &lt;STRONG&gt;finishExport&lt;/STRONG&gt;(exportContextOID):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ctx = ScriptExportModelSettings(exportContextOID)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jan 2020 21:38:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/using-python-to-create-an-object-attribute-from-a/m-p/539825#M7303</guid>
      <dc:creator>timrobinson</dc:creator>
      <dc:date>2020-01-20T21:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to create an object attribute from a rule attribute</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/using-python-to-create-an-object-attribute-from-a/m-p/539826#M7304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This line is missing from the main script:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;ce = CE()&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Otherwise, the python script works for me.&amp;nbsp; I created a test shape that reported values for all the reports you read in the export script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My guess is that maybe your shapes don't have values for some reports.&amp;nbsp; In this case, you'll get an error message in the Log (&lt;EM&gt;Window&lt;/EM&gt; -&amp;gt; &lt;EM&gt;Log&lt;/EM&gt;) which will tell you which line failed.&amp;nbsp; You can check if the report exists before trying to get it:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;if(model.getReports().has_key("GFA.Comm")):
     r = model.getReports()["GFA.Comm"][0]&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:25:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/using-python-to-create-an-object-attribute-from-a/m-p/539826#M7304</guid>
      <dc:creator>CherylLau</dc:creator>
      <dc:date>2021-12-11T23:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to create an object attribute from a rule attribute</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/using-python-to-create-an-object-attribute-from-a/m-p/1393754#M11303</link>
      <description>&lt;P&gt;I have followed these instructions and the python scrips works to export and write FSR to shape attribute, however it appears to be writing the "Max" in the reported value - how can I get it to write the "Sum" column value to a new object attribute?&lt;/P&gt;</description>
      <pubDate>Sun, 10 Mar 2024 07:52:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/using-python-to-create-an-object-attribute-from-a/m-p/1393754#M11303</guid>
      <dc:creator>jabrett</dc:creator>
      <dc:date>2024-03-10T07:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to create an object attribute from a rule attribute</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/using-python-to-create-an-object-attribute-from-a/m-p/1399149#M11319</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/753701"&gt;@jabrett&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Would it be possible for you to share your python export script and the CGA file with the report? Without further information it's hard to assist.&lt;/P&gt;&lt;P&gt;Best,&lt;BR /&gt;Jonas&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 17:13:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/using-python-to-create-an-object-attribute-from-a/m-p/1399149#M11319</guid>
      <dc:creator>JonasObertuefer</dc:creator>
      <dc:date>2024-03-21T17:13:24Z</dc:date>
    </item>
  </channel>
</rss>

