How to call the height value of the shp file data and give the building height value in cga or python.
Solved! Go to Solution.
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.
Hi,
You can find information on how to 'connect attributes' in cga here:
Hope this is what you are looking for.
/**
* 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.)
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.