<?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: Conditional Import Statements for Rules in ArcGIS CityEngine Questions</title>
    <link>https://community.esri.com/t5/arcgis-cityengine-questions/conditional-import-statements-for-rules/m-p/717278#M9397</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unless something changed in CE 2017 that I'm not aware of, conditional imports are not possible in CGA.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Aug 2017 18:52:37 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2017-08-17T18:52:37Z</dc:date>
    <item>
      <title>Conditional Import Statements for Rules</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/conditional-import-statements-for-rules/m-p/717277#M9396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a hypothetical question about importing outside rules. Is it possible to set up conditional imports? I know in python it is very easy to do something like this:&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&amp;nbsp; &lt;SPAN class="keyword token"&gt;try&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; pandas &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; pd
 &lt;SPAN class="keyword token"&gt;except&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# Pandas is shipped with ArcGIS Pro and ArcGIS 10.4 and higher.&amp;nbsp; The previous logic should hopefully prevent users from ever hitting this error.&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddError&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"This BetterBusBuffers tool requires the python library pandas, but the tool was unable to import the library."&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
‍‍‍‍‍&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I was curious if something similar is possible in CGA. In my earliest attempts, I start with a simple import statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;import Street_Text : "Street_Text.cga"‍&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;Then, I figured, because the text for import is just text, I can just replace it with a const.&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;const conditional_text_import= case fileExists("Street_Text.cga"): "Street_Text.cga" else:&amp;nbsp; "/ESRI.lib/rules/General/Text.cga" 
‍import Street_Text : conditional_text_import‍‍&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;P&gt;This however returns an error. I have since tried doing the import statements within rules and other variations (I did not think they would work but I thought I would try). Is this simply not possible in CityEngine? Any alternatives?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My goal is to essentially make a rule not being in the folder not be catastrophic to the rules function. It is a small thing, and there are other options, but I just want to keep a rules user experience a little easier. I think I am especially concerned when the functionality being added is not critical to many people's use cases. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Relevant docs:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://cehelp.esri.com/help/topic/com.procedural.cityengine.help/html/cgareference/import.html?resultof=%22%69%6d%70%6f%72%74%22%20" title="http://cehelp.esri.com/help/topic/com.procedural.cityengine.help/html/cgareference/import.html?resultof=%22%69%6d%70%6f%72%74%22%20" rel="nofollow noopener noreferrer" target="_blank"&gt;import&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using CE 2017. Any thoughts appreciated.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.esri.com/people/CWilkins-esristaff" target="_blank"&gt;CWilkins-esristaff&lt;/A&gt;&amp;nbsp;to your knowledge is this possible?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:42:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/conditional-import-statements-for-rules/m-p/717277#M9396</guid>
      <dc:creator>DavidWasserman</dc:creator>
      <dc:date>2021-12-12T06:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Import Statements for Rules</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/conditional-import-statements-for-rules/m-p/717278#M9397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unless something changed in CE 2017 that I'm not aware of, conditional imports are not possible in CGA.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Aug 2017 18:52:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/conditional-import-statements-for-rules/m-p/717278#M9397</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2017-08-17T18:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Import Statements for Rules</title>
      <link>https://community.esri.com/t5/arcgis-cityengine-questions/conditional-import-statements-for-rules/m-p/717279#M9398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! I just wanted to check from a Jedi master if I was missing something.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Aug 2017 19:02:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-cityengine-questions/conditional-import-statements-for-rules/m-p/717279#M9398</guid>
      <dc:creator>DavidWasserman</dc:creator>
      <dc:date>2017-08-17T19:02:13Z</dc:date>
    </item>
  </channel>
</rss>

