<?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: Redefine attribute in imported script in ArcGIS CityEngine Questions</title>
    <link>https://community.esri.com/t5/arcgis-cityengine-questions/redefine-attribute-in-imported-script/m-p/267787#M3544</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;case Colorby == "BldgTypeCu":&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;okay ?&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, 28 Nov 2013 17:52:53 GMT</pubDate>
    <dc:creator>MatthiasBuehler1</dc:creator>
    <dc:date>2013-11-28T17:52:53Z</dc:date>
    <item>
      <title>Redefine attribute in imported script</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/redefine-attribute-in-imported-script/m-p/267786#M3543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, I have three sequential CGA scripts I would like to keep in separate files for simplicity. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The second one uses "set" to define an attribute (BldgTypeCu) orginally defined in the main script, and then this attribute is used by the last script to set the color of the building. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In theory, should work: however, I get an error message: 'No such attribute:&amp;nbsp; BldgTypeCu in second script' (in essence). If I take the first call to the attribute out of the first script and leave it only in the second, it works, but then the third script does not seem to be able to access it. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How do I fix this error? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here are the three scripts:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the first:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
version "2012.1"

attr ActualUseC = "" 
attr BldgHeight = 0
attr BldgTypeCu = ""
attr Neighbourh = ""
attr ZoningCode = "" 
attr NumberOfSt = "" 
## to color by # of units
#attr Colorby = "NumberOfSt"
## OR to color by biulding use type
attr Colorby = "BldgTypeCu"


import bd1: "BuildingbyType.cga"(BldgTypeCu) #BldgTypeCu in parenthesis to allow imported script to over-ride attribute value in importing script
#import cr1 : "ColorRule.cga"

@StartRule
Footprint --&amp;gt; 
case Neighbourh == "James Bay" || Neighbourh == "": 
 Building
else:
 print("the neighborhood is: "+Neighbourh)
 Building
 color("#f0f0f0")

Building --&amp;gt;
 bd1.Building

&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The second:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;/**
 * File:&amp;nbsp;&amp;nbsp;&amp;nbsp; BuildingbyType.cga
 * Created: 22 Nov 2013 19:02:58 GMT
 * Author:&amp;nbsp; tfrappe
 */

version "2012.1"
attr ActualUseC = "" 
attr ZoningCode = "" 
attr BldgTypeCu = ""
import cr1 : "ColorRule.cga"

Building --&amp;gt;
## SFD
case&amp;nbsp; ActualUseC == "000" || ActualUseC == "002" ||ActualUseC == "020" || ActualUseC == "032" || ActualUseC == "033"|| ActualUseC == "034"|| ActualUseC == "035"|| ActualUseC == "036" || ActualUseC =="041" || ActualUseC == "239":
&amp;nbsp; set(BldgTypeCu,"SFD") 
&amp;nbsp; extrude(rand(6,8))
&amp;nbsp; ColorRule
 
## LMFD
case ActualUseC == "029" || ActualUseC == "030" || ActualUseC == "039" || ActualUseC == "042" || ActualUseC == "047" || ActualUseC == "049" || ActualUseC == "050" || ActualUseC == "051" || ActualUseC == "052" || ActualUseC == "053" || ActualUseC == "057" || ActualUseC == "058" || ActualUseC == "237" || ActualUseC == "287"|| ActualUseC == "285" || ActualUseC == "286" :
 set(BldgTypeCu,"LMFD") 
 extrude(rand(9,12))
 ColorRule 

else:
 set(BldgTypeCu,"OTHER") 
 print("the actual use code is : "+ActualUseC)
 extrude(25)
 ColorRule 
 


ColorRule --&amp;gt;
 cr1.Color
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The third:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;/**
 * File:&amp;nbsp;&amp;nbsp;&amp;nbsp; ColorRule.cga
 * Created: 22 Nov 2013 18:54:39 GMT
 * Author:&amp;nbsp; tfrappe
 */

version "2012.1"
attr Colorby = ""
attr BldgTypeCu =""
attr NumberOfSt = "" 


Color--&amp;gt;
case Colorby == "BldgTypeCu":
&amp;nbsp; case BldgTypeCu == "SFD": color("#FFEBAF")
&amp;nbsp; case BldgTypeCu == "SFD2": color("##F4C362")
&amp;nbsp; case BldgTypeCu == "LMFD": color("#F4C362")
&amp;nbsp; case BldgTypeCu == "HMFD": color("#FFAA00")
&amp;nbsp; case BldgTypeCu == "COMM": color("#FF7F7F")
&amp;nbsp; case BldgTypeCu == "IND": color("#704489")
&amp;nbsp; case BldgTypeCu == "INST": color("#6788CA")
&amp;nbsp; case BldgTypeCu == "MU": color("#FF7F7F")&amp;nbsp; #SAME AS COMMERCIAL FOR NOW
&amp;nbsp; case BldgTypeCu == "CMTY": color("#AB0066")
&amp;nbsp; else: color("#00ffff")
 
 else: color("#0000ff")
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Nov 2013 18:21:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/redefine-attribute-in-imported-script/m-p/267786#M3543</guid>
      <dc:creator>Tom-PierreFrappé-Sénéclauze</dc:creator>
      <dc:date>2013-11-22T18:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: Redefine attribute in imported script</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/redefine-attribute-in-imported-script/m-p/267787#M3544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;case Colorby == "BldgTypeCu":&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;okay ?&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, 28 Nov 2013 17:52:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/redefine-attribute-in-imported-script/m-p/267787#M3544</guid>
      <dc:creator>MatthiasBuehler1</dc:creator>
      <dc:date>2013-11-28T17:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: Redefine attribute in imported script</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/redefine-attribute-in-imported-script/m-p/267788#M3545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry Matt, don't understand your reply. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For simplicity, I've cut some of the script in ColorRule.cga ; there are a couple ways in which I want to color the models, one is by building type (which is stored in the attribute BldgTypeCu), the other is by number of strata (stored in attribute NumberOfSt). The attribute Colorby is the toggle I use to switch between one and the other by feeding it the name of the field I want to color by (though I am not using this other than in the 'case' structure, so could have named the two cases whatever; note that the case "colorby == "NumberOfSt":" has been cut from the example above to simplify the script).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Not sure if that helps to clarify the scripts. If you can tell me more about your suggestion above (if still relevant after I explained this), it might help...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&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>Thu, 28 Nov 2013 21:29:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/redefine-attribute-in-imported-script/m-p/267788#M3545</guid>
      <dc:creator>Tom-PierreFrappé-Sénéclauze</dc:creator>
      <dc:date>2013-11-28T21:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: Redefine attribute in imported script</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/redefine-attribute-in-imported-script/m-p/267789#M3546</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;What I wanted to say is there's the most obvious error in your code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;attr BldgTypeCu =""&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the attribute BldgTypeCu is of the type 'string', an empty string.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;case Colorby == "BldgTypeCu": &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;you are comparing Colorby with a string of the value 'BldgTypeCu' (the word itself), not the actual value of the attribute 'BldgTypeCu'.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You need to remove the quote signs. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry for the confusion .. :rolleyes:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ok ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;m.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Nov 2013 07:55:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/redefine-attribute-in-imported-script/m-p/267789#M3546</guid>
      <dc:creator>MatthiasBuehler1</dc:creator>
      <dc:date>2013-11-29T07:55:53Z</dc:date>
    </item>
  </channel>
</rss>

