Select to view content in your preferred language

How to place a flat roof on top of poles- City Engine CGA rules

269
2
Jump to solution
04-08-2025 02:40 AM
TidimaloMaphoto
New Contributor

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: 
TidimaloMaphoto_0-1744104674808.png

// 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:

TidimaloMaphoto_1-1744104939094.png

 

// 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)

0 Kudos
1 Solution

Accepted Solutions
plfontes
Regular Contributor

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

View solution in original post

2 Replies
plfontes
Regular Contributor

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

TidimaloMaphoto
New Contributor

Thank you so much @plfontes .
I adjusted a few parameters and the shape came out perfectly. 

TidimaloMaphoto_0-1744273320472.png