While attending DynaNight at Autodesk University 2017, I was sipping away at some sugary sweet cocktails and chatting with Jostein Olsen about fun things we were cooking up. He obviously had much more interesting ideas than I had and one of them really caught my attention: putting a QR Code package in the Dynamo package manager.
Now, I hadn’t thought of QR codes since I watched Gone in 60 Seconds on my first DVD back in the 2000s, but after the conference I had some ideas with what to use them for.
Essentially, I wanted to pass design data through to physical building elements. We’ll call it data tracking or some form of asset management, because I’m not sure what else to call it. Whatever it is, it is the opposite of creating PDFs and killing data.
The idea is to take all the parameters of a Revit element, place them in a QR code, and save that QR code as an image parameter in that element (do you know a QR code can hold up to 4,000 characters of text?). When fabricators receive the model and fabricate their parts, they could then place that QR sticker on the part.
I haven’t built what I thought of next, but I want to put the concept out there. After the QR is placed, at every point in the building process, that QR is scanned. When it’s built, shipped, arrives to the site, installed, and inspected its scanned and sent to a website. That website keeps track of that object, allows the user to see its design data, and shows maintenance schedules for it. This allows building management/maintenance to see the data the engineers/architects created when they designed the space.
Below is the Dynamo workflow to place a QR code filled with any parameters/data into as many elements as you want. Big thanks to Konrad Sobon for the Image Import python code and Jostein Olsen for the QR Code package. Below is the full script.
For this example, we use the Revit 2018 basic sample house and get all the furniture elements in it. This group could be replaced with any other category or lists of categories.
Next, we take all parameters of the elements, turn them into strings, and join them. From this we use the QR Code node to turn it into an image.
The QR image has to be saved somewhere so a directory path is given and it is written to it.
This isn’t completely necessary but I wanted to rerun this multiple times and therefore wanted to delete the old QR codes generated from previous runs here.
Below are the meat and potatoes of the script. In order to place an image into a parameter, it must be imported and placed in any view. In our case, we create a drafting view for the images to be dumped into. Utilizing Konrad’s python code, we keep the image import options as is and set those.
We need to modify Konrad’s code for the Image Import by adding a for loop to accept multiple image file paths. See below for the modified code.
# Copyright(c) 2015, Konrad K Sobon # @arch_laboratory, http://archi-lab.net # Import Element wrapper extension methods import clr clr.AddReference("RevitNodes") import Revit clr.ImportExtensions(Revit.Elements) # Import DocumentManager and TransactionManager clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager # Import RevitAPI clr.AddReference("RevitAPI") import Autodesk from Autodesk.Revit.DB import * import sys pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib' sys.path.append(pyt_path) #The inputs to this node will be stored as a list in the IN variable. dataEnteringNode = IN filePath = IN iio = IN view = UnwrapElement(IN) RunIt = IN elementlist =  for i in filePath: # try: # errorReport = None if RunIt: # Start Transaction doc = DocumentManager.Instance.CurrentDBDocument TransactionManager.Instance.EnsureInTransaction(doc) newElement = clr.StrongBox[Element]() doci = doc.Import(file = str(i), options = iio, view = view, element = newElement) elementlist.append(newElement.Id) # End Transaction TransactionManager.Instance.TransactionTaskDone() else: errorReport = "Set RunIt to True." # except: # if error accurs anywhere in the process catch it # import traceback # errorReport = traceback.format_exc() #Assign your output to the OUT variable #if errorReport == None: OUT = elementlist #else: # OUT = errorReport
I like to create parameters if my scripts depend on them, therefore we add a QR Code parameter to the category that we are looking at.
Finally, we take the imported image and set it as the image parameter of the corresponding element.
Here is the drafting view showing the QR codes in a pile and the final parameter in the elements.
And that’s it! Hopefully you’ll get some use from this or it gives you some other ideas. As always, if you have any questions please reach out.