Any way I could merge and align faces parallel to the initial shape with CGA?

1626
4
Jump to solution
07-25-2016 03:01 AM
LR
by
Occasional Contributor III

I'm constructing a pile of dirt that changes shape depending on a couple of variables. It starts out pointy and then flattens out. Using the roofHip operation seems to work for this however I'm stuck with the flattening out part. I comp'd the roof in X direction but I can't flatten it out. It should look like the pile on the right. Any ideas?

Perspective.png

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DevinLavigne
Occasional Contributor III

Got it. I think this should do it....

/**
 * File:    dirtpile.cga
 * Created: 26 Jul 2016 06:25:45 GMT
 * Author:  devlavigne
 */

version "2016.0"

@Range(1,89)
attr roofAngle=45

@Range(1,89)
attr dirtHeight=1

@StartRule
Start-->
  roofHip(roofAngle)
  split(y) {dirtHeight:DirtPile | '1:NIL} 

DirtPile-->
  comp(f){side:Sides| bottom:Base. | top:Top}

Top-->
  color(1,0,1)
  extrude(40)

View solution in original post

0 Kudos
4 Replies
DevinLavigne
Occasional Contributor III

I'm not exactly sure what you want to do, but I think the code below will do what you want. Its essentially splitting the height of the "roof" and removing the top. I've added a couple attributes - for the height of the dirt pile and the angle of the dirt pile to give you a little more control if you need it.  Hope this helps.  Devin

/**
 * File:    dirtpile.cga
 * Created: 26 Jul 2016 06:25:45 GMT
 * Author:  Devin Lavigne
 */

version "2016.0"

@Range(1,89)
attr dirtAngle=45

@Range(1,89)
attr dirtHeight=1

@StartRule
Start-->
  roofHip(dirtAngle)
  split(y) {dirtHeight:Dirt | '1:NIL} 

Screen Shot 2016-07-26 at 1.43.05 AM.png

0 Kudos
LR
by
Occasional Contributor III

Well, that's odd. I did try this approach, except that I split the components first and used the top. As you can see in the blue pile, my NIL part is invisible (as I thought it should be, the documentation says it deletes the face).

Perspective.png

Unfortunately I might need to build on the plateau, and when I close the hole in your approach so I have a face to use, the pile pops back in (red pile).

For now I (mostly) solved the problem by using setback(), extruding the "core", closing the hole in the setback ring, then creating a roof. The roof center is cut out by splitting the roof so its edges meet the core top, the correct values for this are conjured employing the dark arts of trigonometry. Unfortunately, this is not 1000000000% accurate, resulting in tiny gaps or (rarely) invisible faces.

CGA for blue pile:

version "2016.0"

@Range(1,50)
attr pAngle = 30

@StartRule
Lot -->
  color(0,0,1)
  roofHip(pAngle)
  comp(f){top: Plateau}

Plateau -->
split(y){7: Side. | ~1: NIL}
0 Kudos
DevinLavigne
Occasional Contributor III

Got it. I think this should do it....

/**
 * File:    dirtpile.cga
 * Created: 26 Jul 2016 06:25:45 GMT
 * Author:  devlavigne
 */

version "2016.0"

@Range(1,89)
attr roofAngle=45

@Range(1,89)
attr dirtHeight=1

@StartRule
Start-->
  roofHip(roofAngle)
  split(y) {dirtHeight:DirtPile | '1:NIL} 

DirtPile-->
  comp(f){side:Sides| bottom:Base. | top:Top}

Top-->
  color(1,0,1)
  extrude(40)

0 Kudos
LR
by
Occasional Contributor III

Ah dang, I should stop breaking up everything into faces first. This works great, on uneven surfaces as well. Piles sitting on steep hills can also be evened out by aligning the scope to the Y axis.

Thanks!

0 Kudos