POST
|
Hi Matthias, Thank you for the examples. I set global attributes in my example code in the first post but did not succeed since the execution order was different from what I expected. I would like to follow the recursive approach you sketch in your last post and the previous example to mark corner lots here. My question is: Is it possible to define a recursive rule which accesses individual edges of the base shape (to e.g. query their length using scope.sx), store the calculated values and finally call a rule which performs operations on the same (unmodified) base shape? I don´t see a way to access components of a shape, calculate some values based on them, and resume calling a rule with the current shape. It seems that the logic is limited to a top-down order... Regards, Mirko
... View more
05-30-2012
03:48 AM
|
0
|
0
|
626
|
POST
|
Hi Matthias, Thank you for your answer. So is there a way to set attributes initially as described above? Since its not possible (as fas as I understand) to use geometric operations like "comp" within functions (not rules) how would an iterative algorithm work? We are looking forward developing more complex CGA algorithms. Can you provide some hints in which direction CGA will develop in upcoming releases? Regards, Mirko
... View more
05-29-2012
06:47 AM
|
0
|
0
|
626
|
POST
|
As far as I understand the execution of rules follows a strong hierarchical order where the uppermost rule is fully executed first before "child" rules are executed (independent of the call-order). Is this a correct interpretation? I did not find it in the docs yet. I´ve checked a previous example you gave here. There you use a recursive algorithm leading to the correct execution of "child" rules. Following my approach I´m wondering if it is actually possible to calculate and globally store values e.g. in attributes using convenience functions like "comp" etc. ... Regards, Mirko
... View more
05-28-2012
04:30 AM
|
0
|
0
|
626
|
POST
|
Hi, I´m currently diving into CGA scripts. I´ve checked out this forum, read some articles in the documentation and worked through several examples. Still some aspects of how CE evaluates rules remain a mystery to me. As a start I want to calculate the length of all edges at the side of a street. I tried the following code but the attributes are never set (the edge indices are correct though):
attr streetSideLengthMin = 0
attr streetSideLengthMax = 0
Street -->
SetupStreetAttributes
print("After SetupStreetAttributes")
<more code following here>
SetupStreetAttributes -->
[comp(e){ all : calc}]
calc -->
case comp.index == 0 || ((comp.index > 1) && ((comp.index - 1) % 3 == 0)):
print("Before: " + streetSideLengthMin)
set( streetSideLengthMin, streetSideLengthMin + scope.sx)
print("After: " + streetSideLengthMin)
else:
case comp.index == 2 || ((comp.index > 3) && (comp.index % 3 == 0)):
set( streetSideLengthMax, streetSideLengthMax + scope.sx)
else:
NIL
Probably I am completely misusing the rules here... 😉 My goal is to initially calculate the two attributes and then go on executing the shape generation process based on the attribute values. I decided to use rules instead of functions because of the comp operator which actually comes in quiet handy here. Using "print" messages for debugging indicated that the execution order is not as expected e.g. like in usual programming languages. Even the print statement after "SetupStreetAttributes" seems to print to console before "SetupStreetAttributes" is actually executed. I would be happy to understand why this approach doesn´t work and how the task could be achieved correctly. If anybody can point me to the appropriate docs I would be happy to go through it. Regards, Mirko
... View more
05-24-2012
07:16 AM
|
1
|
7
|
1146
|
Title | Kudos | Posted |
---|---|---|
1 | 05-24-2012 07:16 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|