How to generate buildings with distinct architecture using city engine?

3400
10
11-28-2016 02:25 AM
mansimittal1
New Contributor II

When we have distinct architectures of buildings ,then how can we create such buildings in city engine?Do we have to create cga rule file separately for each distinct architecture buildings or there is other solution?

Tags (1)
0 Kudos
10 Replies
CherylLau
Esri Regular Contributor

You could create different cga files for each style, but one of the advantages of writing cga to generate buildings is that you can create a variations just by changing the attribute values in the cga file.  For example, you could have an attribute that specifies the height of the building, the window size, the facade color, or if there are facade decorations.  You can have attributes to describe many different factors.  Then, each initial shape or building footprint can be assigned different values for these attributes to produce different buildings from the same rule file.  Randomness and probability can even be built into the rules to increase variety.  Of course, if the architectural styles you have in mind are completely different, it may become easier at some point to just write separate cga rule files for each different style.  That programming choice is up to you.

0 Kudos
mansimittal1
New Contributor II

okay. I have more than 3000 lots with totally different architecture styles.This will be very hectic.Are there no easy solutions other than creating separate cga files?

0 Kudos
DavidWasserman
Occasional Contributor III

In many cases, you may not need separate files, but just keep a well built case -else structure that makes the breakpoints in style divergence clear. You do need to code each style you want to represent however, and fine a way to tie them back to your lot files whether it is random assignment or attribute driven. Generally, you can create a valid scene at the scale you are talking about by just grabbing the top 3 styles and developing rule parameter options for them.
If you want to go the multiple rule file approach to keep it separated, as most buildings share some common massing elements, it is possible use one rule as a library for the others. Essentially any code you see as a duplicate you just put into your library rule and call them in the style rules. 

David Wasserman, AICP
CherylLau
Esri Regular Contributor

I guess my response wasn't too clear.  One of the advantages of using cga to generate buildings is that you can generate a variety of buildings (of different styles) with just a single cga file.  Attributes can describe many different factors that you can set to different values.  You can specifically create preset styles using the style keyword.  Probability and randomness can also help generate variation or choose different styles.  It is possible to generate 3000 different buildings with just a single rule file.  If you do want to separate some code into multiple files, you can use imports as well to create links between files.

mansimittal1
New Contributor II

After long time I am back to this problem.And I am trying to code it all in single file but there are many problems I am facing and even do not know if my approach towards dynamic coding is correct or not.

0 Kudos
DavidWasserman
Occasional Contributor III

Hi Mansi, 

Can you share any details about the issues are you facing? Is there a specific element we can help with? 

David Wasserman, AICP
0 Kudos
mansimittal1
New Contributor II

 Rule files

Yeah ,please look in these rule files snapshots.

testfile.cga is the main file and it is calling 4 other rule files which has same code as in floor0.cga snap shown here.

As my requirements are already specified that each building design structure would be different.Also floor will have different dimension & number of apartments and it is possible that every floor has different design structure too.Like there are many conditions that can happen.

Because of which I am bound to create new file for every floor.And this could lead to more than 100 files.

Also if I keep one file than I have to create as many different variables as floors because if variables kept same they would change other floor values.

So I want to know if my approach is right towards creating more than 1000 buildings at a time? What changes can I do to my coding so that it would not become lethargic.

0 Kudos
CherylLau
Esri Regular Contributor

The advice that I could give is to look at what your floors have in common, and see if you can find some common attributes.  They don't have to share the same values.  If so, then you can probably write a single floor rule that covers all cases.  If not, then maybe you do need several floor rules.

For example, the floor rule can have an attribute for the number of apartments.  In the parent rule, you can set this attribute to different values for each floor using set().

set Operation 

This rule sets the number of apartments to 1 for the ground floor and sets the number of apartments to 10 for all other floors.

Floor -->
   case split.index==0:
      set(floor.numApts, 1)
      f0.floor
   else:
      set(floor.numApts, 10)‍‍‍‍‍‍
      f0.floor

Remember that you can also have attributes like floorLayout which can have values such as {"GrandLobby", "OShaped", "SingleHallwayWithApartmentsOnEachSide"}.  Then, in the floor rule, based on this attribute, you can decide whether to create a single large lobby, a floor with apartments arranged around the edges in an O shape, or a floor with a single hallway down the middle and apartments on each side.  These are just simplified examples to illustrate some things you can do with attributes.

0 Kudos
JRAdams
New Contributor III

Is there a location to find cga rules? Like those for generating buildings?

0 Kudos