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.
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
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 <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">500</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">500</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">500</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">500</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> shape <SPAN class="operator token">=</SPAN> ce<SPAN class="punctuation token">.</SPAN>createShape<SPAN class="punctuation token">(</SPAN>None<SPAN class="punctuation token">,</SPAN> rect1x1<SPAN class="punctuation token">)</SPAN> ce<SPAN class="punctuation token">.</SPAN>setAttribute<SPAN class="punctuation token">(</SPAN>shape<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Height'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">50</SPAN><SPAN class="punctuation token">)</SPAN> shapeRule <SPAN class="operator token">=</SPAN> <SPAN class="string token">"rules/extruder.cga"</SPAN> ce<SPAN class="punctuation token">.</SPAN>setRuleFile<SPAN class="punctuation token">(</SPAN>shape<SPAN class="punctuation token">,</SPAN> shapeRule<SPAN class="punctuation token">)</SPAN> ce<SPAN class="punctuation token">.</SPAN>setStartRule<SPAN class="punctuation token">(</SPAN>shape<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Lot'</SPAN><SPAN class="punctuation token">)</SPAN> ce<SPAN class="punctuation token">.</SPAN>generateModels<SPAN class="punctuation token">(</SPAN>shape<SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">)</SPAN> ce<SPAN class="punctuation token">.</SPAN>waitForUIIdle<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
CGA
attr Height <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN> @StartRule Lot <SPAN class="operator token">-</SPAN><SPAN class="operator token">-</SPAN><SPAN class="operator token">></SPAN> extrude<SPAN class="punctuation token">(</SPAN>Height<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.