Extrude a block with python

550
1
12-07-2020 05:04 PM
cadop
by
New Contributor

I am working on a project that uses python to generate road networks, which by enclosing spaces automatically creates lots with blocks inside. I am able to set an attribute to the block, but I can't find how to extrude the block or set a height attribute to make it a building.

For example, I can set a height attribute, and when I click after the script runs it shows that height (based on the "Animation" script tutorial https://doc.arcgis.com/en/cityengine/2019.0/tutorials/tutorial-10-python-scripting.htm

 

def set_building(ce):
    lots = ce.getObjectsFrom(ce.scene, ce.withName("*Block*"))
    ce.setSelection (lots)
    print(ce.selection())
    
    for blocks in lots:
        ce.setAttributeSource(blocks, "height", "OBJECT")
        ce.setAttribute(blocks, "height", 10)

 

 

However this does nothing to the model. I see that CGA reference has an 'extrude' method, but the python reference is missing it.  

How is this done?

0 Kudos
1 Reply
DavidWasserman
Regular Contributor

I see the confusion. There is a distinction between CGA & Python in CityEngine. CityEngine I think still uses the Jython API for workflow automation and set up. You have the right idea here. The issue you are having is you need to apply a rule written in CGA to build geometries from lots. I recommend looking at sample rules for this in the tutorials. 
This script contains an example used to create different street combinations based on provided attributes as an example. It is based on attributes of the Complete Street Rule.  

David Wasserman, AICP
0 Kudos