How to call the height value of the shp file data and give the building height value in cga or python.

1075
3
Jump to solution
06-14-2022 08:49 PM
Labels (1)
leehwichan
New Contributor II

How to call the height value of the shp file data and give the building height value in cga or python.

leehwichan_0-1655264988625.png

 

0 Kudos
1 Solution

Accepted Solutions
plfontes
New Contributor III

Try to connect the object attribute to the model by matching attribute names. Change your attribute name on your code from 'attr Building_Heignt = 20' to 'attr NMLY = 20'.

I believe CE will use the value '20' only if it doesn't get any value from the object's attribute.

View solution in original post

3 Replies
plfontes
New Contributor III

Hi,

You can find information on how to 'connect attributes' in cga here:

https://doc.arcgis.com/en/cityengine/latest/help/help-inspector.htm#ESRI_SECTION1_5050267501F04FC28B...

Hope this is what you are looking for.

0 Kudos
leehwichan
New Contributor II

/**
* File: simpleBuildingAgain.cga
* Created: 15 Jun 2022 06:23:37 GMT
* Author: user
*/

version "2019.1"


attr Building_Heignt = 20


@StartRule
Lot -->
extrude(world.y, Building_Heignt)
BuildingMass

BuildingMass -->
comp(f) {side : Facade | top : Roof}

Roof -->
setupProjection(0, scope.xy, scope.sx, scope.sy)
projectUV(0)
texture("roofs/roof.tif")

attr Groundfloor_Height = 5
attr Upperfloor_Height = 3

WallSidePart_Width = 1

//texture("facades/textures/brickwall.jpg")
//texture("facades/textures/dirtmap.15.tif")
//texture("facades/textures/brickwall normal.jpg")
Facade -->
setupProjection(0, scope.xy, -1, -0.5)
projectUV(0)
texture("facades/textures/brickwall.jpg")
setupProjection(2, scope.xy, scope.sx, scope.sy)
projectUV(2)
set (material.dirtmap, ("facades/textures/dirtmap.15.tif"))
setupProjection(3, scope.xy, scope.sx, scope.sy)
projectUV(3)
set (material.normalmap, ("facades/textures/brickwall normal.jpg"))
split(x) {WallSidePart_Width : Wall | ~1 : Facade_Main | WallSidePart_Width : Wall}

Facade_Main -->
split(y) {Groundfloor_Height : Floor | ~1 : Upper_Floors }

Upper_Floors -->
split(y) {~Upperfloor_Height : Floor }*

attr Tile_Width = 5

Floor -->
split(x) {~Tile_Width : Tile}*

attr Tile_side_Width = 1.5

Tile -->
split(x) {Tile_side_Width : Wall | ~1 : Tile_Main | Tile_side_Width : Wall}

attr Window_BaseHeight = 0.9
attr Window_Hegiht = 1.4

Tile_Main -->
split(y) {Window_BaseHeight : Wall |Window_Hegiht: Window | ~1 : Wall}

texName = fileRandom("window/sash_window_*.jpg")

Window-->
setupProjection(0, scope.xy, scope.sx, scope.sy)
projectUV(0)
texture(texName)

 

 

(I wrote a script like this and I don't know where to fix it.)

0 Kudos
plfontes
New Contributor III

Try to connect the object attribute to the model by matching attribute names. Change your attribute name on your code from 'attr Building_Heignt = 20' to 'attr NMLY = 20'.

I believe CE will use the value '20' only if it doesn't get any value from the object's attribute.