Dynamo Users Meet-Up

If you’re living in United Kingdom and you’re interested in Dynamo, computational design and automation, I strongly recommend getting involved with UK Dynamo User group. So far I’ve attended two meetings and it was a time well spent! Each meeting consists of 3-4 longer presentations and quick round of tips & tricks from other users. When the official part is over, there’s time for casual networking and it usually involves a pub nearby. In terms of topics covered on those meetings, some of my favorite lectures were about macros, add-ins, modelling from point cloud, computational design in structural engineering and linking Revit with Power BI.

Here’s a picture from May meeting, you can even spot me there:You can find them here, there’s an event happening in Manchester, 7th September.

Watch out when the tickets are out – because they might be gone within an hour!

Painting walls using Dynamo

Hello again! As it turns out, moving all your livelihood to a different country is quite an absorbing process and I had to skip on my blogging for a bit. But now I’m back and…

 

…picture a massive hospital model in Revit that’s in dire need of painting. The default tool for applying paint is not the most efficient one to say the least and the deadline is approaching. What do you do? Since taking a holiday break was not an option, my second guess was to use Dynamo for that.

This script can be broken into two parts.

First part deals with sorting the walls per width and base constraint. To my surprise, the former wasn’t as straight forward I thought (It might have something to do with family structure for “Walls” category). In order to get the value of width, I used the following combination of two Python scripts:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
items = UnwrapElement(IN[0])
typelist = list()
for item in items:
      try:
        typelist.append(item.Document.GetElement(item.GetTypeId()))
      except:
        typelist.append(list())
OUT = typelist

and:

check = IN[0]
items = IN[1]
     if isinstance(check, (list)): OUT = items
else: OUT = items[0]

Combining those two with some basic BoolMasks leaves me with a list of walls-to-be-painted. Now to the second part – applying paint.

I must admit, my Revit API game isn’t the strongest, so to get this (simple, I know) script working I had to consult it with a colleague of mine. The final product is as follows:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc =  DocumentManager.Instance.CurrentDBDocument

elems = UnwrapElement(IN[0])
paintmat = UnwrapElement(IN[1])

TransactionManager.Instance.EnsureInTransaction(doc)
for elem in elems:
     for geo in elem.get_Geometry(Options()):
             for face in geo.Faces:
                      doc.Paint(elem.Id, face, paintmat.Id)
TransactionManager.Instance.TransactionTaskDone()
OUT = elems

One interesting thing I’ve noticed is that the Python part of this Dynamo script seems to be “remembering” the values, i.e. when I’m done with painting one selections of walls and I want change the values by which I sort them – this script insists on painting the original selection. I think I’m missing something obvious here, feel free to enlighten me.

 

What really grinds my gears, Revit edition

I’ve been working in Revit for few years now, and I can’t imagine going back to the “old way” – daily struggles with AutoCad. Having said that, this cooperation doesn’t always go as smooth as planned. There are major problems, there are minor obstacles and there are some odd design decisions I can’t really wrap my head around.

With this lighthearted post I want to share three examples of small annoyances, in no particular order

1. 3D section box
…and more specificly – those small arrows that controls it. Why are they so small? If I got a dollar for every missed click, I’d be a rich man with shares in Autodesk!

 

2. Orient to View list
You can’t scroll it with your mouse wheel. there’s no scroll bar. You have to click that little arrow and wait for the right view to finally pop on your screen. That might not be a big deal for smaller buildings, but having to work on 60+ high rise, it was a daily annoyance.

3. Aligining sections
Well, you can’t do it. I mean, you can’t use the align tool to do it, there are workarounds, but the intuitive thing to do – no, Revit won’t let you. Is there something I’m missing here?

 

Now that I vented a bit, something positive – if you’re in Boston area, you can sign up for the tour of Autodesk Build Space. Having seen it myself – strongly recommended, especially if you’re interested in production, 3d printing and CNC.

Offtopic – big changes ahead!

Sorry for the brief hiatus! I’m in the middle of relocating to United Kingdom to take on some new challanges. To take my mind off all this, I was travelling around Morocco for last two weeks and I’ve been taking pictures of some interesting buildings I came across. I’d like to share three of them with you:

    

The first one is of course the famous Hassan II Mosque in Cassablanca. I encourage you to read more about the this building, it has an interesting history and it’s quite a unique one in terms materials and construction process.

Following objects don’t share the same significance as the Hassan II Mosque, but they immediately caugth my eye. The first one seems to be an abandond cafe at the Cassablanca Corniche, second – residential building in city of El Jadida. No idea about the architect and the year they were built.

As you can see, I’m not a professional photographer, but I enjoy taking a picture of nice architecture whenever I see it!

One more thing – Moroccans have a chain of shops named “BIM”, I couldn’t resist taking a picture:

Purging unused linestyles in Revit with Dynamo and Python

All the best in 2017!

Lately, I’ve been dealing with models with far too many (i.e. more than zero) exploded dwgs inside, and being able to clean up all those leftover linestyles was crucial to me. Once you have to deal with 500+ positions when drafting a single detail, the blow to productivity is far too severe. Purging would be a smart move, yes?

As far as I know, you can’t achieve that with default purge functionality, and to my surprise – it’s not so obvious in Dynamo either. I’ve digged through internet (This thread was very helpful), and at some point I’ve realized that using Python was inevitable. I was reluctant, because my programming skills are basic at best, but as it turns out, “basic” is good enough and I’ve managed to complete my purging script. Here’s how it works:

LinePurge

 

My goal was to do as much as possible in “vanilla” Dynamo and as little as possible with Python. What you can see here is collecting all the linestyles used in project, saving all the unique ones and cross-checking them with list of linestyles available. This is the important distinction, as the first one can be easily done with basic dynamo nodes, the latter had to be achieved with following Python script:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

TransactionManager.Instance.EnsureInTransaction(doc)
lineStyle = doc.Settings.Categories.get_Item(BuiltInCategory.OST_Lines)
lineStyleSubTypes = lineStyle.SubCategories
listNames = []
listId = []

for i in lineStyleSubTypes:
  name = i.Name
  ID = i.Id
  listNames.append(name)
  listId.append(ID)

TransactionManager.Instance.TransactionTaskDone()
OUT = listNames, listId

We start with the list of all available styles, then we throw away those that are used in the project and those with ID’s below zero (non-deletable system linestyles) – ending with list of unused ones. We feed that list to a second Python script that deletes elements by ID’s.

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
from System.Collections.Generic import *

x = IN[0]
Left = list()
Erased = list()

for Id in x:
  try:
    doc.Delete(Id)
    Erased.append(Id)
  except:
    Left.append(Id)
OUT = Erased, Left

…and we’re done. Use with caution!

Shaft openings in phases – am I missing something?

Bug reporting is always the big point of Inside the Factory meetings with Autodesk. This year they tried to play on my competitive side, using day by day charts with number of bugs reported by us. Well, I didn’t reach the podium, but I’ll come prepared next time! There are couple of things in Revit that just doesn’t look right, and as of version 2017 – some of those bugs still exist.

I’ve spotted this one working on a partially to-be-demolished basement model, and here’s how to replicate it:

We’ll start with modelling main actors of this tragedy:
Structural slab – Phase created: existing, Phase demolished: none
Shaft opening – Phase created: new construction, Phase demolished: none
And for reference:
Structural column A – Phase Created: existing, Phase Demolished: none
Structural column B – Phase Created: new construction, Phase Demolished: none
Chunk of slab – Phase Created: existing, Phase Demolished: New Construction
In summary:

Now let’s go back to the views. Let’s start with the completed one, i.e how does in look at the end of “New Construction” phase:

Seems about right.

Now let’s go to view highlighting the amount of demolishing taking place (it’s the state “between” existing and new construction):
phase2
Lift opening should be marked in red!

So how does it look in the “Show Complete” (end of “Existing”) phase?
phase3
In my opinion – this is incorrect. The “void” part of shaft openings for some reason ignores the phase in which it was created… and to make it more confusing, detail lines are (correctly) gone. When we look deeper, we see that the model element of “Shaft Opening” category is in fact gone… but it’s effect (void in the slab) is showing preemptively.
As I mentioned before – I might be wrong, maybe I’m missing something – please let me know.
And if anyone is interested with the solution I came up with – that’s what chunk of slab is showing – we’ve started modelling separate ones to simulate the effect of creating a new opening in an existing slab. Detail lines were placed manually.

Import & export Excel spreadsheets with Dynamo

It’s November now and I’m back from vacation. I’m hoping to write a bit more as soon as I deal with accumulated work… but in the meantime: more dynamo scripts!
This one was a collaboration between me and a fellow structural engineer working on structural framing for a one particular high-rise in London. The idea goes like this – in order to automatize steel framing updates (and save countless hours), we need to establish a link between structural software and Revit model. Third-party software solutions were out of question, and long story short – we used Dynamo .xls export/import function to fill in the gap.

Export script:
export
Import script:
import

As you can see, there’s no mind blowing programming work involved, but it was customized to fit this particular task, it works and there are some neat node tricks here and there. As for the future development – I need to figure out a smart way to map beams with those from structural software, now it’s being done by finding a matching “RAM number” (project parameter used just for this task).
Hope you find this useful!

Forum Autodesk 2016, Warsaw and what came afterwards

October turns out to be a busy month for me. I’ve just gave my speach at the Autodesk Event in Warsaw few days ago and now I’m in Boston, Massachusetts, waiting for another exciting event by Autodesk. Honestly, I can’t complain, the feedback from Warsaw event was very positive and now even the Boston rain won’t change my mood!

I’ll post some updates about the Bostons testing sessions soon, but I might be restricted by confidentiality agreement with Autodesk… we’ll see. Stay tuned!

img_20161006_111804    img_20161008_112217

Join me @ Forum Autodesk 2016 (Warsaw)

Just a quick update – I’ll be giving a presentation on Forum Autodesk 2016 in Warsaw. I’ll be sharing a stage with two colleagues and each of us will show a different approach to a different, real life coordination problem. My lecture is about everyday use of Dynamo in multidisciplinary projects – more specifically – framing coordination with structural team.

You can learn more about this event HERE