Select to view content in your preferred language

Problem with dividing one facade into different segments with Split Command

741
2
Jump to solution
06-28-2023 10:55 AM
MahnoushMostafavisabet
New Contributor

Hi all,

I have written a CGA code for a building, and I want to divide the left side of the building's facade into three segments and write different codes for each segment. However, I'm facing an issue where CityEngine (CE) divides the facade into segments but repeats the same rule for the first segment for the other segments.

To divide the left facade into different segments, I used the "split" command along the x-axis and assigned the length of each segment as an attribute (attr tile_width). Then, I assigned a new code for each segment. However, it still starts the code of each segment with the code of the first segment and continues with the rest of the codes.

Interestingly, the "split" command works fine for dividing the floors through the y-axis and I can write different code for each section, But when it comes to the x-axis, it doesn't apply them correctly to each segment.

here is my code for the ground floor of the left facade:

attr tile_width1 = 16.33 #lenght of the 1st segment
attr tile_width2 = 43.54 #lenght of the 2nd segment
attr tile_width3 = 17.10 #lenght of the 3rd segment
attr height = 5.68
 
Lot -->
 
    extrude(height) Building  
    
Building --> 
    comp(f){ front : FrontFacade | right : RightFacade | left : LeftFacade| back : BackFacade | top : Roof}
 
 
LeftFacade -->     
    setupProjection(0, scope.xy, 1.5, 1, 0, 0, 1) 
  setupProjection(2, scope.xy, scope.sx, scope.sy)
  split(y){ groundfloor_height: GroundfloorleftSide | { ~floor_height: FloorLeftside }* }
  texture(textureLeft)
  projectUV(0)
 
GroundfloorleftSide -->
split(x) { tile_width1 : FrontSeg1 | tile_width2 : FrontSeg2 | tile_width3 : FrontSeg3 }   
FloorLeftside -->
split(x) { tile_width1 : FrontSeg4 | tile_width2 : FrontSeg5 | tile_width3 : FrontSeg6 }
 
 
 
## LeftFacade
FrontSeg1 -->
    split(x){  3 : Wall
            |  1.4 : split(y){ ~1: Wall | 1.2: Window | ~0.4: Wall }
            |  2 : Wall
            |  1.2 : split(y){ 0.03: Porchfloor | 2.3: Door | 0.1 : PorchShade | ~2: SolidWall }
            |  4 : Wall
            |  1.4 : split(y){ ~1: Wall | 1.2: Window | ~0.4: Wall }
            |  0.6 : Wall
            |  1.2 : split(y){ 0.03: Porchfloor | 2.3: Door | 0.1 : PorchShade | ~2: SolidWall }
            |  4 : Wall
            |  1.2 : split(y){ 0.03: Porchfloor | 2.3: Door | 0.1 : PorchShade | ~2: SolidWall }
            |  5 : Wall
            |  1.4 : split(y){ ~1: Wall | 1.2: Window | ~0.4: Wall }
            | 5 : Wall } 
 
FrontSeg2 -->
split(x){  0.2 : Wall
            |  1.4 : split(y){ ~1: Wall | 1.2: Window | ~0.4: Wall }
            |  0.6 : Wall
            |  1.4 : split(y){ ~1: Wall | 1.2: Window | ~0.4: Wall }
            |  0.6 : Wall} 
            
FrontSeg3 --> 
split(x){  0.2 : Wall
            |  1.4 : split(y){ ~1: Wall | 1.2: Window | ~0.4: Wall }
            |  0.6 : Wall
            |  1.2 : split(y){ 0.03: Porchfloor | 2.3: Door | 0.1 : PorchShade | ~2: SolidWall }
            |  5 : Wall
            |  1.4 : split(y){ ~1: Wall | 1.2: Window | ~0.4: Wall }
            |  0.6 : Wall} 

 

In the attached picture, CE repeats the code for FrontSeg1 not only for the first segment but also for the second and third segments. In other words, for each segment, CE applies all three FrontSeg1, FrontSeg2, and FrontSeg3 together (starting from FrontSeg1). However, I only want FrontSeg1 code for the first segment, only FrontSeg2 for the second segment, and FrontSeg3 for the third segment without any repetition.

I would really appreciate your help. Thank you in advance!

Mahnoush

 

3D View1.jpg

 

 

0 Kudos
1 Solution

Accepted Solutions
CherylLau
Esri Regular Contributor

The FrontSeg1 code is repeated for each left face because your building has 3 faces classified as left, and the comp in Building separates each left face individually as a different shape and applies the LeftFacade rule to each of the three faces.  This means that each of the three left faces will start with FrontSeg1.

 

I think you wanted all the left faces to be processed together as a single shape.  This can be achieved by using the = operator instead of the : operator.

Building -->
    comp(f){ front: FrontFacade | right: RightFacade | left= LeftFacade| back: BackFacade | top: Roof }

 

Additionally, instead of using a split to separate the three parts, you might be able to use a comp and use indices as the selectors to identify the 3 parts.

Building --> 
    comp(f){ front: FrontFacade | right: RightFacade | left= LeftFacade| back: BackFacade | top: Roof }

GroundfloorleftSide -->
    comp(f) { 0: FrontSeg1 | 1: FrontSeg2 | 2: FrontSeg3 }   
FloorLeftside -->
    comp(f) { 0: FrontSeg4 | 1: FrontSeg5 | 2: FrontSeg6 }

 

 

 

View solution in original post

2 Replies
CherylLau
Esri Regular Contributor

The FrontSeg1 code is repeated for each left face because your building has 3 faces classified as left, and the comp in Building separates each left face individually as a different shape and applies the LeftFacade rule to each of the three faces.  This means that each of the three left faces will start with FrontSeg1.

 

I think you wanted all the left faces to be processed together as a single shape.  This can be achieved by using the = operator instead of the : operator.

Building -->
    comp(f){ front: FrontFacade | right: RightFacade | left= LeftFacade| back: BackFacade | top: Roof }

 

Additionally, instead of using a split to separate the three parts, you might be able to use a comp and use indices as the selectors to identify the 3 parts.

Building --> 
    comp(f){ front: FrontFacade | right: RightFacade | left= LeftFacade| back: BackFacade | top: Roof }

GroundfloorleftSide -->
    comp(f) { 0: FrontSeg1 | 1: FrontSeg2 | 2: FrontSeg3 }   
FloorLeftside -->
    comp(f) { 0: FrontSeg4 | 1: FrontSeg5 | 2: FrontSeg6 }

 

 

 

MahnoushMostafavisabet
New Contributor

Hi CherylLau,

Thank you for your help!

0 Kudos