AnsweredAssumed Answered

Conditional Import Statements for Rules

Question asked by Holisticbynature on Aug 12, 2017
Latest reply on Aug 17, 2017 by Holisticbynature

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: 

            import pandas as pd
            # Pandas is shipped with ArcGIS Pro and ArcGIS 10.4 and higher.  The previous logic should hopefully prevent users from ever hitting this error.
            arcpy.AddError("This BetterBusBuffers tool requires the python library pandas, but the tool was unable to import the library.")

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"

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

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: 



Using CE 2017. Any thoughts appreciated. 

Chris Wilkins to your knowledge is this possible?