Sunday, September 14, 2014

Practical Dynamo - Excel Linking 2: Keeping Track of Your Families

There is an advantage to living in a small city/country with a disproportionately large contingent of ADSK employees: I have great access to the development team!

In my last blog post, I pointed out how the list of values for the selected families were not in alphabetical order:


This was because the instances were sorted in order according the GUID:


Without taking the GUID into account, it was impossible to map data from excel back to the appropriate family instance.  If i sorted the data in Excel, I would end up with results like this one:


Not quite hitting the mark in terms of "Data Integrity".  What i needed was a way to export the data, taking the GUID into account, and then be able to map values to the right object on the return trip.

I got in touch with my friends Sharad and Ritesh at ADSK in Singapore and told them about my problem.  These guys love both a challenge and customer feedback; its a match made in heaven because i am a man with problems.

Explaining my dilemma to them, they knew exactly how to solve it and we developed these 2 scripts.

THE OUTPUT:

I included the UniqueID into the index stack:

Making my excel spreadsheet look like this:

THE INPUT:
Now when i bring the data back from Excel, there is the index for my elements included.  The order of the GUIDs will inherently match the order of the lists for the other data indices.

What the boys at ADSK told me about was a command ElementSelector.ByUniqueID.  They made me create a code block like you see above and then plug that into SetParameterByName node.  Now DYNAMO will pick my instances by name and in the correct sorted order.

And I am whole again!


The ElementSelector.ByUniqueID is a "hidden command" apparently.  It was in the user menu previously, but the team took it out because they couldn't think of a scenario where it would be useful!  BIMTroublemaker to the rescue!

This whole process makes me happy like ordering from the secret menu at In & Out!












Tuesday, September 2, 2014

Practical Dynamo - Excel Linking

At some time or another, I think we have all grumbled about Revit's lack of interest in communicating with Excel.  The minions of Bass implored us "LINK TO MS/ACCESS!!!"

yeah right....

In response many of us have expended resources on bi-directional excel links using the API.  Sometimes purchased, sometimes internally developed, but there was always a substantial cost involved.

Then along comes DYNAMO.  There is not shortage of pretty pictures of its iterative design capabilities but i'm more practically minded. I realized in an instant that this was the tool that could give me an on the fly, bi-directional excel link... if only i could figure it out.

I've taken some babysteps and i thought i would share.  There is a hardcore group of guys using it, but i am doing my part to spread the word to the mass market.

Here's what i did, starting with a field of orbs.


I've given all the orbs instance marks of AAA to KKK.  My goal is to export the data to excel, add a column in excel with new data, and finally port the new data it back into the "Comments" field.



Getting the Data Out

First thing was to make a new DYNAMO file that I called "Excel Out.dyn"

I'll work from Left to right through the steps

Family Types - Identifies the family type within the Revit model you would like to work with.
All Elements of Family Type - Tells DYNAMO to select them.

Element.GetParameterValueByName - Returns a list of the values for a given parameter within the selected families.
String - Literally a string of characters.  In this case, the name of the parameter i want DYNAMO to get for me.  This kind of work is case-sensitive.

Watch - These are the boxes that will let us see what DYNAMO is doing.  The box on the left shows me the list of values in the "Mark" parameter.  Its not in alphabetical order and I don't care.  On the right is the list of values for the "Comments" parameter.  Its empty, which is accurate.

List.Create - Now i am compiling the data i've culled. index0 refers to the list of values from the "Mark" parameter, index1 refers to the list of values from the "Comments" parameter.

List.Transpose - The previous lists were formatted as columns, however when Dynamo and Excel talk, the data should be formatted by row.  This button reorganizes the data.  Now i have a list for each family instance where item [0] = the "Mark" parameter and item[1] = the "Comments" parameter.

Excel.Write - This is the node which will open an excel file and write to it, but it needs some instructions
File Path - Tells DYNAMO where to find the .XLSX file
sheetName - Must indicate which sheet within the workbook is to be referenced.  I use a text string to indicate
startRow & startCol - Tells DYNAMO where to start reading the spreadsheet
data - Is looking for the lists we created earlier

I hit the RUN button in the bottom left corner.  It thinks for a second then i open my excel file and i have this:

Perfect.  My exported values are in the first column, the second column is blank as anticipated.  For now i am still ignoring the lack of alphabetical order.

Getting the Data In

Using the CONCATENATE function in excel, i went ahead and added the data in column b that i will pump back into my families.



For this part, I made a new DYNAMO file that I called "Excel In.dyn"

Again I'll work from left to right:

File Path - Gets the Excel file
String - text string to indicate which worksheet
Excel.Read - The node which tells DYNAMO to open the file and read it
Watch - Showing me what it comes up with.  Notice how it has made me a series of lists showing what was in each row.

List.Transpose - This is what turns the list of data by rows into a list of data by columns
List.GetItemAtIndex - This is an instruction to pull a particular list out of the list of lists.
Number - "1" pointed at the "index" slot tells it that i want list [1]
Watch - You can see that it has isolated the data i want

Element.SetParameterByName - This is where the magic happens.  This is the node which will write to data to the parameters in your families.  Of course it needs some information.
In the element slot we get:
Family Types - Indicates the families available in the model.
All Elements of Family Type - Tells it to select the indicated family.
In the parameterName slot i use a String node to indicate the parameter i want to write, "Comments".
The value slot links back to me previously isolated data.

I hit the RUN button again and success!


There is still some ways to go with this but i am really happy that i have made some headway.  More help is available here from guys who are lightyears ahead of me:

http://dynamobim.org/

Sunday, August 10, 2014

Modelling The Finnish Drum

One of the highlights of being BIMTROUBLEMAKER is that i occasionally get emails from readers asking me for help in figuring out how to generate forms.  A few weeks back, I got an email asking about how to make this in Revit:





Not a lot to work with, but enough.  I get it, a column that hugs the face of a drum and rises at an angle.  Simple.  I did it as a conceptual mass to make my life quick and easy.  If this was for a real project, I would have done it as a "Structural Column" family, which is more or less the same steps, except starting with a different template.

So first, lets make the section outline of the column by constraining 2 arcs to the left and right of a reference plane.  This will allow for better control of the angle as this column sweeps around:

I save that profile and nest it into a new family.  This new family has several reference points stacked up and evenly spaced.  The distances are controlled by the overall height of the column.  Each reference point acts as a host for the profile I've created.  Additionally, each reference point's rotation parameter is linked to the angle of the desired column lean.


The parameters involved:



Select all the linework and hit CREATE FORM:


After making a dummy version of the building form, I insert the column and copy/rotate it around:


Annnnnd.... I'm done in less time than it took the dude to right me the original email.





The finished file can be downloaded here:
https://drive.google.com/file/d/0B101ixgLlSGXN29ITHBLV29MQ0E/edit?usp=sharing

Sometimes it feels like I am saving the world, one family at a time.

If you got a problem and need some help, contact our global ministry at bimtroublemaker@gmail.com

Sunday, July 27, 2014

Modelling MBS 2: The Boat


I came to Singapore in 2007 to work on the Marina Bay Sands project.  The building was designed by Moshe Safdie and Associates.  Moshe assembled a very talented and dedicated team of designers to put all the pieces together.  The design for the forms was done in late 2006 into 2007 using Rhino, 3D Max and Maya.  At the time, Revit had yet to introduce the conceptual massing environment.  I've often wondered what the process for generating these forms would have been like had it been done using the more recent capabilities of Revit.  So i did some studying...

Let me be clear at the outset that i don't intend to get these exactly right.  I know there was considerable effort, deliberate nuance and extraordinary care that went into the development of this design.  My intention is to use the forms as examples for a lesson in how we can use Revit's conceptual massing in the form-finding process.

Part 2: The Sky Park

Also known as "The Boat on top of the Hotels" or "The Surfboard".  call it what you want, but this guy was simpler to put together than the hotel forms, that's for sure!




So what we have here is an extrusion along a path with a rounded, long nose and an abrupt tush.  Because the extrusion is dynamic at the ends, the profile i use to make the extrusion will need to change in a controlled manner.  This is a really great example of how reporting parameters and adaptive geometry work together.  We can do this.  First thing is to figure out the section we are going to extrude.


looks like half an ellipse to me.  I'll open a new family using the 'Genric Model Adaptive" template.  Then i host half an ellipse on the adaptive point like so:


The "W" and "D" constraints control the line-work of the ellipse.  However there is also a constraint called "Width_R".  This is a reporting parameter tied to the Shape Handle point on right.  This Shape Handle Point is hosted on the same reference plane as the ellipse, and is also constrained to the XY plane.


Let me explain the parameters here:


"Width_Typ" is the typical desired width of the Boat.  Though not directly controlling the profile, this number will be used in a formula to drive the depth of the ellipse as it reduces at the nose and tush.
"Width_R" is the reporting parameter between the Adaptive Point and the Shape Handle Point.  This will directly drive the width of the ellispe.
"W" is the constraint on the width of the ellipse generated by the autosektch dimension when the linework is initially drawn.
"Depth_Typ" is the desired depth of the form in its typical configuration.  This again won't directly drive geometry but is fundamental in the formula for..
"D" which does control the depth of the ellipse but is driven by a formula which will reduce the depth of form at the same rate as it is being reduced in width.

With this done, we can construct the geometry, beginning with the arc for the mid-section.  I'm a fussy guy.  I like to make 2 arcs off of a primary reference plane.  I think this makes it easier to align the geometry i've created when i insert it to the project later.



Next up i will add an inner arc representing 1/2 the width of the form, nest in my profile, and wire up some formulas.


Select my profile and the path and I'm 1/3rd of the way home.


Getting the nose done is a more complex operation.



First I added an ordinary Reference Point to be placed at the end of the center arc.  Upon this point, i hosted half an ellipse and a straight line.


I added constraints related to the width of The Boat and the length of the nose.


I hosted my profile on the straight line and made sure it was at the 0.0 beginning of the line.


Copied it at intervals along the line, decreasing the interval at the end with the final profile at 0.9999


Picked the profiles to create form and voila!



Tip of the nose looks round enough for this exercise


And the boat is starting to come together



Now what about the tush?


This is not a posterior that would excite Sir Mix-A-Lot.  Kind of flat.  To avoid a bunch of Trig while maintaining the parametric disposition of this exercise, I'll just do it as a 3-point curve.  Again i host a reference point at the end of the center arc.  The 3 points shown all have offsets linked to parameters.


Same straight line as at the nose:


Again i spread out my profiles incrementally




And I'm on a boat...




Have some parameters

 Coming together....






Its a big blue watery roll.....