How to size a shape based on world location?

1359
6
03-16-2017 10:04 PM
RobertYu
New Contributor III

I am creating a number of shapes that represent buildings.  (See attached.)

I want to have the buildings facing south to be shorter, and progressively taller as you go north.

How would I capture that using shape grammar?  Suggestions appreciated!

-Robert

0 Kudos
6 Replies
LR
by
Occasional Contributor III

Maybe you could use the split.index, like so:

@StartRule
Lot --> 
    alignScopeToAxes(y)
    split (x){10: Spli}*

Spli -->
    extrude(split.index)
0 Kudos
RobertYu
New Contributor III

That is brilliant.  Thank you!

0 Kudos
CherylLau
Esri Regular Contributor

If you need to know the positions of the buildings relative to the world, you could also convert scope coordinates to world coordinates using convert() (but using split.index is easier).

convert Function 

0 Kudos
RobertYu
New Contributor III

The next step is for the height of the buildings to respond to the sun location.  For example,

I want the buildings along the southern edge of the lot to be low, and the neighboring ones

progressively taller.  I haven't figured out how to get the heights of neighboring buildings, so I am

using the python export to get building locations and calculating the height using python.

Unfortunately, with Jython, I cannot import modules like "numpy" so it's becoming a bit

of kluge, doing a system call to a python script from within Cityengine's jython.

I feel I am approaching this problem the wrong way.  Suggestions?

0 Kudos
CherylLau
Esri Regular Contributor

Knowledge about neighboring shapes in CityEngine is really difficult and limited.  It's currently limited to the occlusion queries in CGA.  If you figure out a way to do it with Python, it's probably the only way to do it.

0 Kudos
RobertYu
New Contributor III

Thanks for the information.  Perhaps I can import the JTS geometry library into CityEngine to extend the jython functionality.

Update: Getting JTS into cityengine worked, using this article pyright: jython + the JTS geometry library.  Note I had to be

careful with the coordinate system:  CityEngine -z is JTS y.