+ Reply to Thread
Results 1 to 5 of 5

Thread: Variables storage

  1. #1
    Tal Aisenberg
    Join Date
    Feb 2012
    Posts
    14
    Points
    0
    Answers Provided
    0


    0

    Default Variables storage

    Hey,

    Is there a way to store a value at some point in the code so I can use it later - for example:
    I want to determine a building's height based on the plot size and its footprint (in order to get my FAr right). So I need to:

    1. Measure the plot - geometry.area and save it
    2. create the building footprint with ShapeL (or offset / ShapeU....)
    3. now calculate based on a target FAR the height of the building (FAR = plot area / (footprint * no. of stories))
    4. extrude the building to the required height

    Its just that once I've done the shapeU operation I cannot go back to read the plot area as geometry.area(bottom) will now give me the building footprint.

    I tried with assigning the value to a new attr on the Lot rule (just before I divide them) but this doesn't seem to work.

    Cheers
    T


    p.s. working with really tedious urban planners - you know how they can sometimes be :-|

  2. #2
    André Cardoso
    Join Date
    Oct 2011
    Posts
    66
    Points
    1
    Answers Provided
    0


    0

    Default Re: Variables storage

    I'm not sure what you have tried to do already ... but have you tried to use the "set(attr, attrValue)" function?

    Something like this:
    Code:
    @Hidden
    attr originalArea = 0
    
    Lot -->
       print("Original Area", geometry.area)
       set(originalArea, geometry.area)
       BuildShape
    
    BuildShape -->
        shapeL(3, 4){shape: ShapeRule | remainder: NIL}
    
    ShapeRule -->
       alignScopeToAxes(y)
       print("Original Area Again", originalArea)
       print("Current Shape area", geometry.area)
       extrude(world.y, originalArea/8) # calculate height in function of oriignal footprint area
       Shape.
    Does it work?
    André Cardoso
    Developer(3Decide)
    URL: www.3decide.com

    E-mail: andre.cardoso@3decide.com
    Address: PINC UPTEC – Praça Coronel Pacheco, 2,
    4050-453 Porto, Portugal

    http://about.me/andrecardoso

  3. #3
    André Cardoso
    Join Date
    Oct 2011
    Posts
    66
    Points
    1
    Answers Provided
    0


    0

    Default Re: Variables storage

    Another possibility is just to pass the original area down to the next rules, as Rule parameters...
    Code:
    Lot --> 
    Rule2(geometry.area)
    
    Rule2(area) -->
    Rule3(area)
    
    ...
    André Cardoso
    Developer(3Decide)
    URL: www.3decide.com

    E-mail: andre.cardoso@3decide.com
    Address: PINC UPTEC – Praça Coronel Pacheco, 2,
    4050-453 Porto, Portugal

    http://about.me/andrecardoso

  4. #4
    Tal Aisenberg
    Join Date
    Feb 2012
    Posts
    14
    Points
    0
    Answers Provided
    0


    0

    Default Re: Variables storage

    Brilliant, Set does the trick.

    The problem with the second option is that I only need to use the variable in routines 4 or 5 levels down so bit cumbersome to pass it on and on.

    Thanks again,
    T

  5. #5
    André Cardoso
    Join Date
    Oct 2011
    Posts
    66
    Points
    1
    Answers Provided
    0


    0

    Default Re: Variables storage

    Exactly! For me, one the great things added in these recent versions of CE was the capability to use "set()" with attributes defined by us. Things get much cleaner...

    André Cardoso
    Developer(3Decide)
    URL: www.3decide.com

    E-mail: andre.cardoso@3decide.com
    Address: PINC UPTEC – Praça Coronel Pacheco, 2,
    4050-453 Porto, Portugal

    http://about.me/andrecardoso

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts