20120424

Programming Programming

2012-04-05_1416

Buildz is very pleased to welcome Lilli Smith for this guest post.  Lilli is a Principal User Experience Designer at Autodesk, which means she researches and defines the look, feel, and function of the products so that software developers can implement them. While she has contributed to a huge number of Revit features over the years, today she is stepping out of her comfort zone to explore the world of code authoring. 

Lilli here. I'm an architect and longtime Revit/Vasari product designer and sit right next to Zach here in the factory.  I've been thinking a lot about building space programming lately. It's a conceptual design activity that is so ripe for computer programming. Like Zach, I am an architect not a coder.  Of course I do have geek tendencies, work for a software company, and have access to a lot of great coding minds so sometimes I do attempt to dabble.  Inspired by some of the scripts in Nathan Miller's Revit API Notebook, I set out to see if I could figure out how to turn a building program from an excel spread sheet into a model in Vasari using Darren Thomas's Revit Python Shell. I liked that with the Python shell you could quickly cut and paste code, save, and run the script immediately - no compiling or other hurdles. I also really appreciated Nathan’s Python examples as I would have never been able to get started without them since my Python knowledge was pretty much non-existent last week. 

[You can download and follow along with these files.]

I started with a simple family Space.rfa which contains a box and some parameters as well as 14 materials with color names (Red, Blue, Green, etc) that I used for the space “color” parameter. I set up the materials because it was easier for me to just create them once in the family than to figure out how to make and set them using the API. I figured that 14 colors were enough for my immediate purposes and I could always add more or get programmatically more fancy.

clip_image001

The first script MakeSpaceTypes.py does the following in Space.rfa:

1. Reads SchoolProgram.csv

2. Creates a type for each space type (Gym, Cafeteria, Library, Classroom, etc)

3. Set parameters to variables in file

Nathan gave me a little preview of this post on dealing with external data that really helped me get this first script working. I still got really stymied by figuring out how to deal with different data types like materials,  strings, and integers though.  My developer friends had to help me a bit here.

After loading the family into a project, I can run the second script place3D.py which places the defined quantity of each type separated by width and length, and at a defined floor height.  Again, my developer friends helped me figure out how to nest the loops properly.  However, being able to experiment with different things quickly by making edits, saving, and immediately running the script, was key to helping me learn how some of the code worked.

clip_image001[4]

Wah lah!  This is a helpful way to quickly visualize the size of a building program, get a kit of parts into a model and then arrange the blocks on a site to start creating a building.  You could also concurrently do energy simulations to see how much it matters if say your Cafeteria is on the south or north side of your building.  Want to change the proportions of a space?  No problem, just adjust the type and all the instances will update.  Use Vasari alignment locking to keep spaces aligned property as their type dimensions change or just replace everything with the script once they proportions have been tweaked.

To make sure the script would work on any program (given the right format of course), I also tried it on HospitalProgram.csv.  The hospital contains spaces on more floors and illustrated how spaces can also be placed three-dimensionally.  

clip_image001[6]

Of course, all of the Vasari/Revit capabilities of filters and schedules can be used on the model to study the program in different ways.  Here any space type containing "Public" is colored red for example.

clip_image001[8]

clip_image002

In the future, it would be fun to figure out different ways to place the spaces - perhaps based on different groupings or other parameters.  It would also be nice to be able to do the placement part in a visual programming tool like Ian Keogh's Dynamo so that it would be easier to programmatically wire up new possibilities.

Download the space planning Vasari files and python scripts here.

Download the Vasari2.5 RevitPythonShell addin from here.

See Nathan Miller’s RPS examples here.

20120403

Vasari Talk: Visual Programming in Vasari and Revit with Dynamo

2012-03-22_0958

Wednesday, April 4, 2012 11:30 AM - 12:30 PM EDT

Summary: We will demonstrate how Project Vasari and Revit can utilize two emerging trends in conceptual design to explore design variations: visual programming and design optimization.

Learning Goals: At the end of this session, you will be able to:

  • Explain what visual programming is.
  • Demonstrate how to use Project Vasari with the open source visual programming environment Dynamo.
  • Create a sample  flexible parametric model that responds to an automated feedback loop.
  • Design a sample project optimized for local environmental conditions.

Register Now!

Watch Previous Sessions