Select to view content in your preferred language

Exponentially changing attribute in a function in CGA rule

2762
3
Jump to solution
07-05-2016 09:38 AM
GeorgiosAnastasiou
Emerging Contributor

In a CGA rule I have a repeating function that needs to be changing the set attribute value exponentially and not proportionally as I have it now. One way to do it could be by setting an attribute inside the function (like in python), but it is not supported. What would be a way of doing that?

1 Solution

Accepted Solutions
LR
by
Frequent Contributor

You mean something like this?

attr RowRow = 2
attr Expo = 2
attr HoldMe = 0

Lot -->
extrude(5)
color (1,1,0)
print("----------")
DoTheThing

DoTheThing -->
case Expo > 10: EndThis
else: GoGo

GoGo -->
print("Expo old: " + Expo)
set(HoldMe,pow(RowRow, Expo))
set(Expo, Expo+1)
print("Expo new: " + Expo)
print("Exponential!: " + HoldMe)
print("--")
DoTheThing

EndThis -->
#important
print(":D-/-<")
print(":D-\\-<")
print(":D-/-<")
print(":D-\\-<")
print(":D-/-<")
print(":D-\\-<")
print(":D-/-<")
print(":D-\\-<")

View solution in original post

3 Replies
GeorgiosAnastasiou
Emerging Contributor

for example in this case, you can apply it in any footprint and see the shape:

attr Factor = 0.97

attr Depth = 0.01

attr Stop = 0.1

Lot-->

   extrude(Depth)

   center(xyz)

   X

   comp(f) {top : Levels}

Levels-->

   case(scope.sx > Stop) :

      s('Factor, 'Factor, 0)

      center(xy)

      extrude(Depth-0.02)

      X

      comp(f){top : Levels}

   else:

      NIL

The target is in each repetition the attribute "Factor" to be smaller than the previous one. So, the higher the floor, the smaller the size becomes exponentially.

Edit: it should work as I want it with

attr Depth = 0.1

0 Kudos
LR
by
Frequent Contributor

You mean something like this?

attr RowRow = 2
attr Expo = 2
attr HoldMe = 0

Lot -->
extrude(5)
color (1,1,0)
print("----------")
DoTheThing

DoTheThing -->
case Expo > 10: EndThis
else: GoGo

GoGo -->
print("Expo old: " + Expo)
set(HoldMe,pow(RowRow, Expo))
set(Expo, Expo+1)
print("Expo new: " + Expo)
print("Exponential!: " + HoldMe)
print("--")
DoTheThing

EndThis -->
#important
print(":D-/-<")
print(":D-\\-<")
print(":D-/-<")
print(":D-\\-<")
print(":D-/-<")
print(":D-\\-<")
print(":D-/-<")
print(":D-\\-<")
GeorgiosAnastasiou
Emerging Contributor

That was very useful, and by following the log in CGA console I understood exactly how it works.

I found exactly what I needed: the "set" operation to change the attribute inside the function, and the exponential growth of the value, in this case by using the "pow" (power) operation.

Thank you very much Z R!

0 Kudos