<?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: import statement + functions in ArcGIS CityEngine Questions</title>
    <link>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567733#M7664</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ha, this is very very cool, very useful!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I should come by the forums more often &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi guys ..&lt;BR /&gt;&lt;BR /&gt;Yes, this works.&lt;BR /&gt;&lt;BR /&gt;Just usually, I don't import a master rule into an other 'god rule'. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;I try to pass down all values needed from the master rule down to the slave rules, if somehow possible.&lt;BR /&gt;&lt;BR /&gt;What's also not so beautiful is if each slave rule itself imports e.g. a 'general reporting' rule, you will see instances of that rule in the Inspector ( each selectable ), which is visually confusing.&lt;BR /&gt;&lt;BR /&gt;Thus, note the structure in the following example .. I guess it gives the best overall import structures :&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;code in cga file the master file "a.cga", which is assigned to the shape, with Start Rule A :&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import b : "b.cga"
import c : "c.cga"

A --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; b.B

b.Mass --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; c.ReportBottom
&lt;/PRE&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;code in cga file "b.cga" :&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

B --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; extrude(world.y, 10)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Mass
&amp;nbsp;&amp;nbsp;&amp;nbsp; # note that Mass must remain an 'undefined rule', so you'll not be able to avoid the yellow warning.
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;code in cga file "c.cga" :&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
ReportBottom --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; report("BottomArea", geometry.area(bottom) )
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;As you see in those 3 rule files, all content is 'distributed' from the master file 'a' to 'b' and then &lt;STRONG&gt;taken back to a&lt;/STRONG&gt; to be sent to 'c' for reporting.&lt;BR /&gt;&lt;BR /&gt;That way, you can create rules, which e.g. creates all Masses alone, all Roofs alone, all Facades alone and distribute all via the master rule file, then cycle it back.&lt;BR /&gt;&lt;BR /&gt;This is advanced shit, boys !&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 00:27:34 GMT</pubDate>
    <dc:creator>AndréCardoso</dc:creator>
    <dc:date>2021-12-12T00:27:34Z</dc:date>
    <item>
      <title>import statement + functions</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567727#M7658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greetings,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a set of metrics I need to derive from measurements of the geometry of a massing model. The method for calculating those metrics is defined as a function with cga. However, the massing model is created by one of a dozen imported cga files, with the parameter required for the function calculated using rules in those cga files. Is it possible define a function in a "master" cga file, and use that function in an imported cga file with a parameter defined in the imported cga file?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the logic of it, roughed out in CGA:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
## importing.cga
attr function(parameter) = parameter*someCalculation
import importedcga: "rules/imported.cga"&amp;nbsp; (function)
import importedcga2: "rules/imported2.cga"&amp;nbsp; (function)
Rule --&amp;gt; 
case someCondition == True: importedcga.importedRule
case someOtherCondition == True: importedcga2.importedRule
else: NIL

## imported.cga
attr parameter = 0 #empty attribute (to be set within this cga's rule).
attr function = 0 #empty attribute (overwritten by the import statement in importing.cga)
importedRule --&amp;gt; 
set(parameter, geometry.area)
report("metric", function(parameter))
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So far I haven't had much luck in actual finding a solution. The way around doing this is to keep a copy of all functions in each of the imported.cga files...but I was hoping to avoid that so I wouldn't have to edit them all if I need to add other metrics or adjust any of the constants used by the calculations.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you in advance,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Christian&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jan 2013 20:06:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567727#M7658</guid>
      <dc:creator>ChristianGass1</dc:creator>
      <dc:date>2013-01-31T20:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: import statement + functions</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567728#M7659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If I'm reading this right, I think you just need one layer deeper of importing. Currently you have a single CGA file (importing.cga) which imports many CGA files (imported.cga #1 thru N). Those imported files can then import from a single file (what you called a master file). So you have three layers of CGA rather than two. I amended your code below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
## importing.cga
import importedcga: "rules/imported.cga"&amp;nbsp; #(function)
import importedcga2: "rules/imported2.cga"&amp;nbsp; #(function)
Rule --&amp;gt; 
case someCondition == True: importedcga.importedRule
case someOtherCondition == True: importedcga2.importedRule
else: NIL

## imported.cga
import masterFunction: "rules/masterFunction.cga"&amp;nbsp; #(function)
attr parameter = 0 #empty attribute (to be set within this cga's rule).
importedRule --&amp;gt; 
set(parameter, geometry.area)
report("metric", masterFunction.function(parameter))

## masterFunction.cga - All imported.cga files import this file.
attr function(parameter) = parameter*someCalculation&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's a little diagram to show it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]21283[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:27:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567728#M7659</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T00:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: import statement + functions</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567729#M7660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ah - that worked perfectly! Many thanks for the response and example. I have a much better understanding now of what the import statement can do.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The result is attached. The 'imported' cga files mass up the building envelopes for different land uses, with estimates of GFA, population, parking requirements, student generation, etc.:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]21321[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Christian&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2013 14:44:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567729#M7660</guid>
      <dc:creator>ChristianGass1</dc:creator>
      <dc:date>2013-02-01T14:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: import statement + functions</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567730#M7661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi guys ..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, this works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just usually, I don't import a master rule into an other 'god rule'. &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;I try to pass down all values needed from the master rule down to the slave rules, if somehow possible.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What's also not so beautiful is if each slave rule itself imports e.g. a 'general reporting' rule, you will see instances of that rule in the Inspector ( each selectable ), which is visually confusing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thus, note the structure in the following example .. I guess it gives the best overall import structures :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;code in cga file the master file "a.cga", which is assigned to the shape, with Start Rule A :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import b : "b.cga"
import c : "c.cga"

A --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; b.B

b.Mass --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; c.ReportBottom
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;code in cga file "b.cga" :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

B --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; extrude(world.y, 10)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Mass
&amp;nbsp;&amp;nbsp;&amp;nbsp; # note that Mass must remain an 'undefined rule', so you'll not be able to avoid the yellow warning.
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;code in cga file "c.cga" :&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
ReportBottom --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; report("BottomArea", geometry.area(bottom) )
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As you see in those 3 rule files, all content is 'distributed' from the master file 'a' to 'b' and then &lt;/SPAN&gt;&lt;STRONG&gt;taken back to a&lt;/STRONG&gt;&lt;SPAN&gt; to be sent to 'c' for reporting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That way, you can create rules, which e.g. creates all Masses alone, all Roofs alone, all Facades alone and distribute all via the master rule file, then cycle it back.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is advanced shit, boys !&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:27:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567730#M7661</guid>
      <dc:creator>MatthiasBuehler1</dc:creator>
      <dc:date>2021-12-12T00:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: import statement + functions</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567731#M7662</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for that Matthias. Looping back to the master script to aggregate reporting and reporting parameters will definitely simplify things a bit.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Working through this a bit more, it looks like my solution may need be a bit of a hybrid of both methods, if only to avoid the attribute name overrides that can occur when importing rules. Though I think I've worked out some logic to include within my rules that avoids the issue.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am working with essentially two types of functions: those used for analyzing the geometry of models to adjust how massing occurs mid-rule (which do not need to have any parameters exposed in the inspector), and those used for reporting (which don't have exposed parameters at the moment, but certainly could, (e.g., adjustable population-per-dwelling unit assumptions)).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I think my solution is to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-store the geometry-analyzing functions in one cga, and import that into the "imported" cga's, as ChrisWilkinsGeo suggested. -for information to be reported, bring&amp;nbsp; it back to the master.cga, so that the parameters can be managed easily in the inspector, and then report it through the rules executed in another imported cga (containing reporting functions).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Well...all that may not be articulated very well, but it is clear(er) in my head now anyway, and my mock-up seems to be operating as expected. I'll experiment a bit more and draw up a diagram to share once I've sorted it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Christian&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Feb 2013 00:07:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567731#M7662</guid>
      <dc:creator>ChristianGass1</dc:creator>
      <dc:date>2013-02-03T00:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: import statement + functions</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567732#M7663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Cool, a breakdown of your workflow may help other users too ! Including me !&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope you have fun learning CGA !&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matt&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Feb 2013 13:12:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567732#M7663</guid>
      <dc:creator>MatthiasBuehler1</dc:creator>
      <dc:date>2013-02-03T13:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: import statement + functions</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567733#M7664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ha, this is very very cool, very useful!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I should come by the forums more often &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi guys ..&lt;BR /&gt;&lt;BR /&gt;Yes, this works.&lt;BR /&gt;&lt;BR /&gt;Just usually, I don't import a master rule into an other 'god rule'. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;I try to pass down all values needed from the master rule down to the slave rules, if somehow possible.&lt;BR /&gt;&lt;BR /&gt;What's also not so beautiful is if each slave rule itself imports e.g. a 'general reporting' rule, you will see instances of that rule in the Inspector ( each selectable ), which is visually confusing.&lt;BR /&gt;&lt;BR /&gt;Thus, note the structure in the following example .. I guess it gives the best overall import structures :&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;code in cga file the master file "a.cga", which is assigned to the shape, with Start Rule A :&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import b : "b.cga"
import c : "c.cga"

A --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; b.B

b.Mass --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; c.ReportBottom
&lt;/PRE&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;code in cga file "b.cga" :&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

B --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; extrude(world.y, 10)
&amp;nbsp;&amp;nbsp;&amp;nbsp; Mass
&amp;nbsp;&amp;nbsp;&amp;nbsp; # note that Mass must remain an 'undefined rule', so you'll not be able to avoid the yellow warning.
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;code in cga file "c.cga" :&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
ReportBottom --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; report("BottomArea", geometry.area(bottom) )
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;As you see in those 3 rule files, all content is 'distributed' from the master file 'a' to 'b' and then &lt;STRONG&gt;taken back to a&lt;/STRONG&gt; to be sent to 'c' for reporting.&lt;BR /&gt;&lt;BR /&gt;That way, you can create rules, which e.g. creates all Masses alone, all Roofs alone, all Facades alone and distribute all via the master rule file, then cycle it back.&lt;BR /&gt;&lt;BR /&gt;This is advanced shit, boys !&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:27:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567733#M7664</guid>
      <dc:creator>AndréCardoso</dc:creator>
      <dc:date>2021-12-12T00:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: import statement + functions</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567734#M7665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;I try to pass down all values needed from the master rule down to the slave rules, if somehow possible.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;^I'm finding this part of it a bit challenging still. I'd like to work towards using the master to distribute attribute values, but I'd also like to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- store attributes and some logic in several cga files (we'll call them 'attributeStorage'; in my actual work this would be a rule file that contains all the dimensions and conditions described in a single land use zone)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- use some logic in a master cga file to identify which attributeStorage file to reference the attributes from&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- use those attribute values in another rule&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is a simplified version of some test code where I've tried to do this, using the basic structure from Matt's example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
###############
#master.cga
import as1: "C:\filepath\attributeStorage1.cga"
import as2: "C:\filepath\attributeStorage2.cga"
import mr1: C:\filepath\massingRules1.cga
import mr2: C:\filepath\massingRules.cga

attr master_height = 0 #empty

startRule --&amp;gt;
[INDENT]case someLogic: [/INDENT]
[INDENT][INDENT]set(master_height, as1.stored_height) as1.startRule[/INDENT][/INDENT]
[INDENT]case someOtherLogic:[/INDENT]
[INDENT][INDENT]set(master_height, as2.stored_height) as2.startRule[/INDENT][/INDENT]
[INDENT]else: doNothing.
[/INDENT]


as1.as(type) --&amp;gt; as(type)
as2.as(type) --&amp;gt; as(type)

as(type) --&amp;gt;
[INDENT]case type == "type1": mr1.startRule
case type == "type2": mr2.startRule
else: doNothing.[/INDENT]


###############
#attributeStorage1.cga
attr stored_height = 10
attr type = "" #empty
startRule --&amp;gt;
[INDENT]case someLogic: set(type, "type1") as(type)
case someOtherLogic: set(type, "type2") as(type)
else: doNothing.
[/INDENT]


###############
#attributeStorage2.cga
attr stored_height = 20
attr type = "" #empty
startRule --&amp;gt;
[INDENT]case someLogic: set(type, "type1") as(type)
case someOtherLogic: set(type, "type2") as(type)
else: doNothing.
[/INDENT]


###############
#massingRules1.cga
attr master_height = 0 empty #overwritten when imported by master.cga (?)
startRule --&amp;gt;
[INDENT]extrude(master_height)
Massing.[/INDENT]


###############
#massingRules2.cga
attr master_height = 0 empty #overwritten when imported by master.cga (?)
startRule--&amp;gt;
[INDENT]extrude(master_height * 0.5)
Massing.[/INDENT]

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The processing roughly works like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Master.cga contains applies some logic to determine which of the imported 'attributeStorage' cga files to reference. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. The master cga resets an empty attribute based on the corresponding attribute in the imported 'attributeStorage' cga file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. The selected attributeStorage rule applies some logic to set another parameter&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5. The master.cga looks at that rule passed back from attributeStorage to apply some logic to select which massingRule to reference.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6. The massingRule uses the parameter that was reset in step 2 to extrude.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This does work...but only really when I only have to pass one attribute ("master_height") around. It gets very unwieldy and repetitive if I have a dozen attributeStorage cga files storing two dozen attributes each.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To avoid trying to directly pass attributes I was hoping to take advantage of the fact that the attribute of an imported rule is overwritten by an attribute of an importing rule if they have the same name - but don't quite understand the conventions for preserving attributes (or not preserving them) as described in the help documentation for the the import statement. And while I can usually get the importing rule attribute to overwrite the imported attribute, I can't seem to use the convention correctly to preserve an attribute it so I can pass the the value to another imported rule.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a feeling I'm making this more complicated than it needs to be.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Christian&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:27:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567734#M7665</guid>
      <dc:creator>ChristianGass1</dc:creator>
      <dc:date>2021-12-12T00:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: import statement + functions</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567735#M7666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry, but I thnk I'm missing something. I assumed that if you import a rule that the rule would simply run when you call it. I have a series of rules that relate to property use and I want to call that rule for a shape where an attribute on the shape is used to indicate which imported property use rule to apply. Below is my code for the "master" rule:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;version "2012.1"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// land use types&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;attr PROPERTY_USE = " "&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;## importing.cga&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import ruleC2: "rules/C-2.cga"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import ruleC3: "rules/C-3.cga"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import ruleC3_23: "rules/C-3_23.cga"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import ruleCCCOR: "rules/CC-COR.cga"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import ruleCCMH: "rules/CC-MH.cga"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import ruleCCMHX: "rules/CC-MHX.cga"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import ruleCCOR1: "rules/C-COR1.cga"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import ruleCCX: "rules/CC-X.cga"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import ruleCM1: "rules/CM-1.cga"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import ruleCM2: "rules/CM-2.cga"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import ruleI2: "rules/I-2.cga"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import ruleRM7: "rules/RM-7.cga"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import ruleSCS: "rules/S-CS.cga"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import ruleOther: "rules/Other.cga"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;@StartRule&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Lot--&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;case PROPERTY_USE == "C-2" : ruleC2.importedRule&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;case PROPERTY_USE == "C-3" : ruleC3.importedRule&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;case PROPERTY_USE == "C-3(23)" : ruleC3_23.importedRule&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;case PROPERTY_USE == "CC-COR" : ruleCCCOR.importedRule&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;case PROPERTY_USE == "CC-MH" : ruleCCMH.importedRule&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;case PROPERTY_USE == "CC-MHX" : ruleCCMHX.importedRule&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;case PROPERTY_USE == "C-COR1" : ruleCCOR1.importedRule&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;case PROPERTY_USE == "CC-X" : ruleCCX.importedRule&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;case PROPERTY_USE == "CM-1" : ruleCM1.importedRule&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;case PROPERTY_USE == "CM-2" : ruleCM2.importedRule&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;case PROPERTY_USE == "I-2" : ruleI2.importedRule&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;case PROPERTY_USE == "RM-7" : ruleRM7.importedRule&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;case PROPERTY_USE == "S-CS" : ruleSCS.importedRule&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;case PROPERTY_USE == "Other" : ruleOther.importedRule&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;else: NIL&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For each of the "case" lines above I get a yellow exclamation triangle. When you place the cursor over the triangle you get a message like the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;e.g. for ruleC2 the message is "Undefined rule:ruleC2.importedRule"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What am I missing here?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2013 16:43:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567735#M7666</guid>
      <dc:creator>LoringTupper</dc:creator>
      <dc:date>2013-02-20T16:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: import statement + functions</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567736#M7667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Do you have a rule inside those imported CGA files named "importedRule" ?&amp;nbsp; We were using that term as part of pseudo-code in the above examples, so you would need to make that match the name of the rule in the imported file. Is that the issue, or something else?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2013 17:12:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567736#M7667</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-02-20T17:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: import statement + functions</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567737#M7668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Although it's true I didn't have an importedRule in my imported rules when I changed it to StartRule, which I do have, it still gives me the same error message on the yellow triangle warnings. Am I allowed to use a StartRule from an imported rule?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2013 18:14:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567737#M7668</guid>
      <dc:creator>LoringTupper</dc:creator>
      <dc:date>2013-02-20T18:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: import statement + functions</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567738#M7669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you post a code sample or screenshot?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Feb 2013 18:33:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/import-statement-functions/m-p/567738#M7669</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-02-20T18:33:27Z</dc:date>
    </item>
  </channel>
</rss>

