How to assign height attribute to each grid in the grid mesh?

5947
10
Jump to solution
10-12-2015 12:57 PM
TianfangJiang
Deactivated User

Hi guys,

These days I have been working on a shapefile which is imported from the ArcGIS (the shapefile is attached below), In the shapefile the whole building is divided into many grids and each grid contain a specific height attribute with it when imported to the CityEngine. As I want to setup a building model according with the geometry grids and its height attribute, so is there any efficient way for me to read each grid height in the CGA rule and assign the specific height for each grid in the building model?

You can see the whole building footprint is divided into a grid mesh, each grid has its own height attribute. How can I assign the different height to different grid for this geometry in CGA rule or through other kind of method?

For the selected mesh grid, the MEAN_Z is 8.931966 which is shown in the Object Attributes. Each grid contain this kind of height attribute when it was imported to the CityEngine from ArcGIS.

I'm real confused about this problem. Looking forward for your reply.

Thank you for your help!

0 Kudos
1 Solution

Accepted Solutions
MicahTaylor
Frequent Contributor

The CGA code below should do what you want, but be sure and look at other building rules as well and how they work.  There are lots of rules out there that can create 3D buildings already.

http://www.arcgis.com/home/item.html?id=4a62343e07c247299d056321b00f059c

Useful CityEngine Rules

attr MEAN_Z = 2

@StartRule

Extruder-->

    cleanupGeometry(all,1)  #remove this line if you want to keep all the grid vertices in the model

    alignScopeToAxes(y)

    s('1,0,'1)

    extrude(MEAN_Z)

View solution in original post

10 Replies
MicahTaylor
Frequent Contributor

The CGA code below should do what you want, but be sure and look at other building rules as well and how they work.  There are lots of rules out there that can create 3D buildings already.

http://www.arcgis.com/home/item.html?id=4a62343e07c247299d056321b00f059c

Useful CityEngine Rules

attr MEAN_Z = 2

@StartRule

Extruder-->

    cleanupGeometry(all,1)  #remove this line if you want to keep all the grid vertices in the model

    alignScopeToAxes(y)

    s('1,0,'1)

    extrude(MEAN_Z)

TianfangJiang
Deactivated User

Hi Micah,

Thank you so much for helping me, and sorry about replying you so late. I have tried the code you gave me, but it does not modify the geometry to what I want. Can the code you gave me read each grid's MEAN_Z attribute from the shapefile automatically and also make the height attribute be assigned to the building model?

With thanks,

Best Regards,

Tianfang Jiang

0 Kudos
TianfangJiang
Deactivated User

Hi Micah,

I think I didn't describe my question very clearly. The shapefile in ArcGIS are the pictures below which can show that the height for each grid is different from each other. And when the shapefile is imported to the CityEngine, the height attribute for each grid is also imported. But I don't know you how to read and assigned each height attribute automatically by the cga code.

Thank you for your patience.

This is the 2-D grid mesh geometry and the table on the right side is the height attribute for each grid:

This is the 3-D view of the building I want to build in CityEngine which the height of each grid is different from each other:

With thanks,

Bests,

Tianfang Jiang

0 Kudos
LeileiDuan1
Occasional Contributor

Tianfang,

Try to create a height attribute in the rule file and assign it a random value.

Then take a look at this: http://cehelp.esri.com/help/index.jsp?topic=/com.procedural.cityengine.help/html/manual/attrmap/conn...

-Leilei

0 Kudos
TianfangJiang
Deactivated User

Leilei,

I will try your method. Thank you so much for your help.

Tianfang

Sent from myMail for iOS

Thursday, October 15, 2015, 3:41 PM -0400 from Leilei Duan <geonet@esri.com>:

>GeoNet

>How to assign height attribute to each grid in the grid mesh?

>reply from Leilei Duan in CityEngine - View the full discussion

0 Kudos
BenLeslie1
Frequent Contributor

I reckon Micah's answer is correct - just be sure that the 'Source for attribute' is set to 'Object attribute' via the Inspector.

TianfangJiang
Deactivated User

Yes, I think you are right, Micah's answer is right. In the CGA code I just named the attribute as what I want to quote from the object attribute. Then the problem was solved.

Thank you so much for your help!

MicahTaylor
Frequent Contributor

Click this symbol in your inspector window and connect the "MEAN_Z" CGA attribute to your shapefile "MEAN_Z" attr.  Hope this helps.

TianfangJiang
Deactivated User

Thank you so much Micah, Your answer helped me a lot!  I have tried the answers you provided  (the CGA code method and the layer attribute method) and both of them worked really well for my question. Both of them can change the height attribute value corresponding to the shapefile attribute.

0 Kudos