GE2 - DESCRIPTION

GOAL: The focus of the guided exercise is to show an object-oriented pattern in Grasshopper with data-trees. TASK: Select furniture from the furniture library and orient it to a list of rooms.

🦗⬇️⬇️⬇️ Download the start gh script file here ⬇️⬇️⬇️🦗

🦗⬇️⬇️⬇️ Download the end gh file here ⬇️⬇️⬇️🦗


GE2 - FURNITURE REPRESENTATION

CHAIR
  branch 0 "base"
    0 Plane
  branch 1 "2d curves"
    0 Curve
    1 Curve
  branch 2 "3d breps"
    0 Brep
    1 Brep
    2 Brep
    3 Brep
    4 Brep

As you have probably noticed, the data-tree contains the following data: three lists of geometry types i.e. base Plane, 2d Curves and 3d Breps.

STOP AND REMIND YOURSELF THE TASK! TASK: Select furniture from the furniture library and orient it to a list of rooms.

Just image that you need to create multiple data-trees like the one above and orient geometry in those trees to different types of rooms by selecting the appropriate branches. You can try and will soon face the problem of constantly trying to keep track of data-tree branches and items instead of working with a more simplified logic.

OK, WHAT IS THE SOLUTION ?

To reduce the complexity of data-trees in Grasshopper, we introduce the object concept in Grasshopper that is represented by a group. Look in the following image. We first group individual lists into separate groups, then we flatten the list and group again. It means that the group will contains 3 sub-groups, that contains lists of : a) base plane, b) 2d Curves and c) Breps.

Similarly to grouping, we can always go back and ungroup the groups. Look how we go back to the same data-tree representation. The best part is that we can manipulate each group as 1 object not as a data-tree, which is much simpler:

GE2 - LIST OF OBJECTS

Now imagine you need to simplify this representation to two groups:

CHAIR
  branch 0 "base"
    0 Plane
  branch 1 "2d curves"
    0 Curve
    1 Curve
  branch 2 "3d breps"
    0 Brep
    1 Brep
    2 Brep
    3 Brep
    4 Brep
TABLE
  branch 0 "base"
    0 Plane
  branch 1 "2d curves"
    1 Curve
  branch 2 "3d breps"
    0 Brep
    1 Brep
    2 Brep
    3 Brep
    4 Brep

Look at the end of the panel, that we only have to objects only:

GE2 - TRANSFORMATION OF FURNITURE

Groups in grasshopper are treated as geometry objects. Therefore we can move, rotate, scale i.e. transform them. And since we do not need to work data-trees these operations are relatively straight-forward. Let’s try to orient the chair around the table.

WAIT WHAT’S WRONG?

The “orient” components requires input “A”, that was skipped. To orient the chair correctly we need to extract the base plane. The simplest solution would be to take the plane of the chair. But let’s try to learn a little bit about the data-trees. Try to ungroup the group and extract the first item of the data-tree. In this case we use component “Split tree”. This component requires a mask, that corresponds to the data-tree path. The “?” symbol means - take any path, while the “ID” means take the exact path. Here we say: take the first path items, that ends with index “0”:

As a general example, we can extend this example to the orientation of chairs in an auditorium:

GE2 - ORIENT A LIST OF FURNITURE TO MUTLIPLE ROOMS

Now that we know how to create a furniture object we can create a set of furniture. As an example we are using a bathroom, whose walls are subdivided into planes. The planes will be used to orient the furniture to.

Following part represents the 5 furniture: a bath, two sinks, wc and a washing machine:

Here we add planes on the room polygons:

To perform the plane to plane transformation:

Lastly we can extract individual objects: planes, curves or breps using “Match Text” component via following flags: Closed Brep = “Closed Brep” Curves = “Curve” Plane = “O*”