CityEngine Python Scripting: Batch grow streets and export as shape file

07-10-2014 06:03 PM
New Contributor

Hi all,

I'm fairly new to CityEngine but am hoping to build a python script that will allow me to batch grow a series of street networks (with some set parameters) and export each street network to a shape file as follows:

Pseudo code:

Start a new scene

Do while i < 100


     -growstreets(with some parameters)

     -select streets

     -export streets as .shp file with name: "streets" & i & ".shp"

     -select streets

     -delete streets

     i ++


I'm not new to programming but I am new to CityEngine and python.

I assume this is possible? !If anyone could point me in the direction of some suitable examples it would be much appreciated.

Many Thanks


edit: I am playing with ce.growStreets(graph, settings) - however this function requires that I specify a graph from which streets are grown. Using the UI I can simply graph->grow streets in a blank world - can someone suggest how I do the same thing in a script (i.e. not pass a graph or pass an empty one). Thanks

edit2: OK - I am slowly moving forwards here - the following will create a new street network each time it is run, now i just need to export , delete the layer etc.

from scripting import *

# get a CityEngine instance

ce = CE()

def test():

    newGraph = ce.addGraphLayer('new')



if __name__ == '__main__':



At this stage I'm unsure if a mod should delete this thread - but perhaps it will be use to someone else just starting out.

edit3: Close to a final solution - if I am doing this in a very cumbersome way please let me know


Created on Jul 11, 2014

@author: Stephen


from scripting import *

# get a CityEngine instance

ce = CE()

def batchGrowStreets():

    for i in range(1,11😞

        ##Create a new graph layer

        newGraph = ce.addGraphLayer('new')


        ##Grow streets on it



        ##Select them

        graph = ce.getObjectsFrom(ce.scene)


        ##setup the export file

        exportSettings = SHPExportGraphSettings()

        exportSettings.setFilename(ce.toFSPath("testCE" + str(i) + ".shp"))


        ##Export graph as shape file

        ce.export(graph, exportSettings)


        ##delete everything


if __name__ == '__main__':



2 Replies
New Contributor II


how owe did you get on with this? I'm looking at getting roads generated from city engine into Infraworks and this would be really useful



0 Kudos
Esri Regular Contributor

Hi Neil,

Thank you for your question.

CityEngine is a versatile software that supports export to Autodesk data formats:

Supported File-Based Data Formats | InfraWorks | Autodesk Knowledge Network

Here is a suggestion for each data type:

All these exporters can be automated with CityEngine Python CE Help - Python Scripting Category Commands .

0 Kudos