Can I call python scripts outside of the GUI?

3103
8
02-02-2016 07:12 PM
ChristianShiel1
New Contributor III

I want to call the ce python scripts without having to run the gui so I can automate tasks from command line.

0 Kudos
8 Replies
DanPatterson_Retired
MVP Esteemed Contributor

not much  listed, but they are related to tools

Features From CityEngine Rules—Help | ArcGIS for Desktopand there is nothing listed in the arcpy information that accompanies arcmap   What is ArcPy?—Help | ArcGIS for Desktop   unless you have separate documentation and the python access is cryptically kept separate.

And I am assuming you are referring to this reference to python Esri CityEngine | Features

0 Kudos
ChristianShiel1
New Contributor III

I want access to these (the non GUI related) functions:

Help -

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Well, you have to have CityEngine installed and you have to know the rule package location on disk.

>>> # ---- CityEngine ---
>>> import arcpy
>>> import sys
 >>> # http://pro.arcgis.com/en/pro-app/tool-reference/3d-analyst/features-from-cityengine-rules.htm
>>> # http://desktop.arcgis.com/en/arcmap/10.3/tools/3d-analyst-toolbox/features-from-cityengine-rules.htm
>>>
>>> arcpy.CheckOutExtension("3D")
'CheckedOut'
>>>
>>> # syntax
>>> # FeaturesFromCityEngineRules_NOALIAS (in_features, in_rule_package, out_feature_class)
>>> # arcpy.FeaturesFromCityEngineRules_3d("in_polygons", "rules.rpk", "out_multipatches")

So in the last example, you are using the rules.rpk and importing 3D features and exporting multipatches.  The link I sent Esri CityEngine | Features  provides some overview.  So since I don't have it installed, then in theory, you should be able to import a package and if you know what it is you want to do, you go to here

(the python interface help   http://cehelp.esri.com/help/index.jsp?topic=/com.procedural.cityengine.help/html/manual/python/pytho...

Sorry, I don't have time to download the trial and give it a run, but in the documentation, they have some examples etc

0 Kudos
CarlBester1
New Contributor II

Hi Christian,

I had a similar question two days ago. Still no answer yet:

CityEngine python commands in external IDE?

Regards,

Carl

0 Kudos
BenLeslie1
Regular Contributor

I'm sure there was an old post on here from a few years ago that answered this question.  Fairly sure the answer was no - couldn't find it and I'm not sure if the answer is likely to have changed - this article is the only thing I could find:

python – Use Esri CityEngine features external code – | The Answer Web

0 Kudos
ChristianShiel1
New Contributor III

I do not understand why there is no official answer. I am confused as to how the support for CityEngine works.

It seems that the console is running Jython so I wonder if it may have to go through Jython?

0 Kudos
by Anonymous User
Not applicable

Hi Christian,

In general, with CityEngine, an official answer will come from our R&D center in Zurich. That is where CityEngine is developed. Unfortunately, when we get to work in the mornings, at least here in the Redlands office, they are 9 hours ahead of us, and are just getting off work when we get in. Hence an overnight lag in some answers.

If you have CGA questions, I can answer them, but I can't answer this question.

I would agree with Ben's answer. You probably must run the CE Python (yes, Jython) commands from inside CE.

Dan is right that you can run the GP Tool, "Features from CityEngine Rules", from an external IDE, but you want to run things from the CE libraries.

Thomas Fuchs​ or Cheryl Lau​, can you ask someone about this issue? It is also asked in Carl's post here: CityEngine python commands in external IDE?

Thanks!

Chris

CherylLau
Esri Regular Contributor

No, sorry, it is currently not possible to call CE python scripts from outside of the GUI/externally.  It's good to know that there's a demand for this though, so we appreciate your post.