Select to view content in your preferred language

CGA Rules: Calculating the area of an offset plot shape

720
3
07-18-2022 08:56 AM
DPG
by
Emerging Contributor

Hi there

 

I am building a CGA rule that extrudes a building shape that is dependent on the area of the lot. I can easily attain the area of the lot using the "geometry.area" function. 

 

However, now I wish to add an offset to my building. This can be represented by the green area in the picture below. I want to extrude the red area for the new building, and doing so is simple enough.

 

DPG_0-1658159334029.png

 

However, I want the building height to be dependent on it's footprint (the red area). How can I calculate the area of the red shape, as opposed to the entire plot area? I assume I can using the geometry.area function - but ESRI's CGA reference on geometry functions is unclear for me:

 

https://doc.arcgis.com/en/cityengine/2019.0/cga/cga-geometry-function.htm#ESRI_SECTION1_D013B37BD423...

 

Can anybody offer any guidance? Thanks!

 

 

0 Kudos
3 Replies
plfontes
Regular Contributor

Hi,

The geometry.area function is related to the shape you call the function in. So for instance, if you place it within the rule for the inner shape of your plot, this will calculate the area of the inner shape only. Here is an example: 

 

@StartRule
Lot -->
  offset(5) 
  NewLot
  report("The entire Lot area", geometry.area)

NewLot -->
  comp(f) {inside: Inner | border: Offset}

Inner -->
  report("The inner area only", geometry.area)
  color(1,0,0)

Offset -->
  report("The offset area only", geometry.area)
  color(0,1,0)

 

Hope this helps clarify it. 

 

0 Kudos
DPG
by
Emerging Contributor

Thanks for your response. I would like the area of the inner plot as an attribute - not as a report. As far as I can see I don't think that this is possible with the proposed solution

0 Kudos
plfontes
Regular Contributor

Hi, the code snippet above is not a solution but an example of the function use. You can use the geometry.area function of your red area in your calculations and get the correct area as long as it is within the inner shape. 

How do you plan to relate the building height to the building footprint?