Relationship of attributes in Imported Rules

427
2
12-21-2021 02:07 PM
MattOlsen
New Contributor III

Hi everyone, 

I have a simple 'floor area' rule based on one of the tutorials that takes a extruded shape, splits it into building floors, and then creates 'floors' from the bottom face of those floors, to report floor areas. 

 

@Enum("Retail", "Commercial", "Residential")
attr Use = "Retail"

attr floor_height = 4

Init-->
split(y){ floor_height : Floors (Use) }*

Floors(type)-->
comp(f) {bottom: reverseNormals Floors_Areas(type)}

Floors_Areas(type)-->
case type == "Retail":
report("GFA.Retail", geometry.area)
color("#ff5733")

case type == "Commercial":
report("GFA.Office",geometry.area)
color("#44ff44")

else:
report("GFA.Residential",geometry.area)
color("#4444ff")

 

I've imported this rule into a 'master' rule which creates the basic volumes.

In the master rule I have 2 volumes, a ground floor volume, and an upper floor volume (which should be split into multiple floors by the imported 'floorarea' script.

 

import floors : "SplitAreas.cga"

@Enum("Retail", "Commercial", "Residential")
attr Use = "Retail"

@Enum("Yes", "No")
attr GroundFloor_Retail = "Yes"

attr groundfloor_height = 7

attr floor_height = 4

 

[script to create extrusions omitted]

GroundFloor-->

set(floor_height, groundfloor_height) 

# above - I'm attempting to set the floor height used in the imported rule to the ground floor height attribute set in the master rule)

case groundfloor_retail == "Yes":

set(Use, "Retail")

floors.Init

else:

floors.Init

 

UpperFloors-->

floors.Init


I need to to somehow set both the value of "Use" and of "floor_height" in the imported script for the ground floor volume separately - see the attempts at doing this in bold above (this doesn't work).

In the example below, the value for "Use" (Commercial / Green) and floor_height (5) is successfully being pushed from the master rule into the imported rule and floors that creates. But for the ground floor mass, I'm trying to set the floor_height to 8, and for the use to be "Retail" / red.

Is that possible, or do I need to create a separate rule to call for the ground floor since it's height and use are different?

MattOlsen_0-1640124292578.png

 

0 Kudos
2 Replies
Clover4
New Contributor II

I need to to somehow set both the value of "Use" and of "floor_height" in the imported script for the ground floor volume separately - see the attempts at doing this in bold above (this doesn't work).

In the example below, the value for "Use" (Commercial / Green) and floor_height (5) is successfully being pushed from the master rule into the imported rule and floors that creates. But for the ground floor mass, I'm trying to set the floor_height to 8, and for the use to be "Retail" / red.

Is that possible, or do I need to create a separate rule to call for the ground floor since it's height and use are different?

 

It would be easiest to pass the height and usage from CGA rule 1 to import rule 2 than to try an override.   How are your exports from rule 1 to 2 setup up?  Are they parameterized?  

Quick edit: no they are not.   floors.Init   should be something like floors.Init(height,usage).  You will have to adjust your Init start rule to have parameters too.

0 Kudos
MattOlsen
New Contributor III

That's it! Thanks so much Brian. I had initially parameterised this, but not correctly. Rejigged slightly and it's working like a charm.

If anyone sees this thread in future and wants a description of the working solution I'd be happy to run through it.

0 Kudos