Hi everyone 👋
I am working on creating a Carport CGA rule in City Engine. The carprt looks like a table, please assist with this cga rule for, I would like to have the roof sit on the poles and not be displaced like that.
Here’s what I’ve done so far:
Rule 1:
// Attributes
attr carportWidth = 5.0 // Width of the carport
attr carportDepth = 3.0 // Depth of the carport
attr carportHeight = 0.2 // Thickness of carport roof
attr poleHeight = 2.0 // Height of poles
attr poleWidth = 0.1 // Thickness of poles
attr carportColor = "#313333" // Color for roof and poles
// Start Rule
Footprint -->
s('1, 0, '1) // Normalize size (1x1 base)
PlaceCornerPoles // Place poles first
t(0, poleHeight, 0) // Move up to top of poles
Roof // Add roof directly at top of poles
// Roof definition
Roof -->
color(carportColor)
s(carportWidth, carportHeight, carportDepth)
center(y)
primitiveCube()
// Place poles at the four corners (aligned to roof corners)
PlaceCornerPoles -->
CornerPole(0, 0)
CornerPole(carportWidth, 0)
CornerPole(0, carportDepth)
CornerPole(carportWidth, carportDepth)
// Corner pole placement (centered on corner point)
CornerPole(xPos, zPos) -->
t(xPos - poleWidth/2, 0, zPos - poleWidth/2)
Pole
// Pole definition
Pole -->
color(carportColor)
s(poleWidth, poleHeight, poleWidth)
center(y)
primitiveCube()
Rule 2:
// Attributes
attr carportheight = 2.0 // Height of carport roof
attr poleheight = 2.0 // Height of support poles
attr polewidth = 0.1 // Thickness of poles
attr carportColor = "#313333" // Color for both roof and poles
// Start Rule
Footprint -->
s('1, 0, '1) // Normalize size (1x1 base)
extrude(carportheight)
comp(f) { top: Roof | side: NIL }
PlaceCornerPoles
// Roof definition
Roof -->
color(carportColor)
// Place poles at the four corners
PlaceCornerPoles -->
CornerPole(0, 0)
CornerPole(0, 1)
CornerPole(1, 0)
CornerPole(1, 1)
// Corner pole placement
CornerPole(xPos, zPos) -->
t(xPos, 0, zPos)
Pole
// Pole definition
Pole -->
s(polewidth, poleheight, polewidth)
center(y)
primitiveCube()
color(carportColor)
Solved! Go to Solution.
Hi @TidimaloMaphoto ,
I took a different approach, created two branches. One for the roof and one for the poles and worked independently.
version "2024.1"
attr poleWidth = 0.5
attr carportHeight = 10
attr slabHeight = 1
attr carportColor = "#313333"
scale_on_X = scope.sx - 2 * poleWidth
scale_on_Z = scope.sz - 2 * poleWidth
plot -->
color(carportColor)
Poles
Roof
Poles -->
s( scale_on_X , '1, scale_on_Z )
center(xz)
extrude(carportHeight)
comp(e){vertical: Edge}
Edge -->
center(xz)
rotateScope(90,90,0)
primitiveCylinder(12, poleWidth, carportHeight)
Roof -->
extrude(carportHeight)
comp(f){top: Slab}
Slab -->
extrude(slabHeight)
Check if that is what you were trying to do.
Cheers
Hi @TidimaloMaphoto ,
I took a different approach, created two branches. One for the roof and one for the poles and worked independently.
version "2024.1"
attr poleWidth = 0.5
attr carportHeight = 10
attr slabHeight = 1
attr carportColor = "#313333"
scale_on_X = scope.sx - 2 * poleWidth
scale_on_Z = scope.sz - 2 * poleWidth
plot -->
color(carportColor)
Poles
Roof
Poles -->
s( scale_on_X , '1, scale_on_Z )
center(xz)
extrude(carportHeight)
comp(e){vertical: Edge}
Edge -->
center(xz)
rotateScope(90,90,0)
primitiveCylinder(12, poleWidth, carportHeight)
Roof -->
extrude(carportHeight)
comp(f){top: Slab}
Slab -->
extrude(slabHeight)
Check if that is what you were trying to do.
Cheers