How do I programmatically create building footprints and assign a height attribute to the lot in CityEngine?

1206
2
10-22-2016 05:18 PM
SandeshIyer
New Contributor

I want to create building footprints in City Engine programmatically and specify the density of lots in a specific region and assign a height attribute for the buildings to each lot? I need to achieve all this using CGA rules and python. Can anyone point me in the right direction? I'm new to CityEngine. 

0 Kudos
2 Replies
DanPatterson_Retired
MVP Emeritus

If you are new to the software, have you seen the help topics and help files.

Help - 

The rules are covered within and can be searched

0 Kudos
LR
by
Occasional Contributor III

This should help you getting started. It creates a 500x500 rectangle, gives it an attribute plus value, assigns a CGA rule and triggers model creation. Create the CGA rule ("extruder.cga") first.

Python

rect1x1 = [0,0,0, 0,0,500, 500,0,500, 500,0,0]
 shape = ce.createShape(None, rect1x1)
 ce.setAttribute(shape, 'Height', 50)
 shapeRule = "rules/extruder.cga"
 ce.setRuleFile(shape, shapeRule)
 ce.setStartRule(shape, 'Lot')
 ce.generateModels(shape, False)
 ce.waitForUIIdle()‍‍‍‍‍‍‍‍

CGA

attr Height = 0
@StartRule 
 Lot --> 
 extrude(Height)