Hi All,
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:
<SPAN class="keyword token">try</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">import</SPAN> pandas <SPAN class="keyword token">as</SPAN> pd
<SPAN class="keyword token">except</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token"># Pandas is shipped with ArcGIS Pro and ArcGIS 10.4 and higher. The previous logic should hopefully prevent users from ever hitting this error.</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddError<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"This BetterBusBuffers tool requires the python library pandas, but the tool was unable to import the library."</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I was curious if something similar is possible in CGA. In my earliest attempts, I start with a simple import statement:
import Street_Text : "Street_Text.cga"<SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
Then, I figured, because the text for import is just text, I can just replace it with a const.
const conditional_text_import= case fileExists("Street_Text.cga"): "Street_Text.cga" else: "/ESRI.lib/rules/General/Text.cga"
import Street_Text : conditional_text_import<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN></SPAN>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?
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.
Relevant docs:
import
Using CE 2017. Any thoughts appreciated.
CWilkins-esristaff to your knowledge is this possible?