August 10, 2018

Dynamo: Export Views and Sheets from Revit - Part 2

First post in this series [Part 1]

This post will cover the part of the graph that gets the list of Views and/or Sheets from a user-selected ViewSheetSet that are to be exported.
As noted in Part 1, the user has to create a View/Sheet Set in Revit® and add all of Views and/or Sheets to be exported to that set. The user enters the name of that set into a string node, labeled ViewSheetSet Name - String in the green-colored group labeled 2. Enter Name of Set to Export. Just above that, the Element Types node is set to the ViewSheetSet type, which is then fed to the All Elements of Type node to get a list of all of the ViewSheetSet objects in the active project. This list of ViewSheetSet objects is passed to the Element.Name node, which generates a list of the names (as strings) of those ViewSheetSets. This list is passed to the IndexOf node, along with the name that the user entered, to determine the index of that name on the list. Finally, the list of ViewSheetSets and the index of the desired ViewSheetSet are passed to the List.GetItemAtIndex node, to get that ViewSheetSet object.

During my initial testing, I passed the ViewSheetSet object to an Element.Parameters node, to see what information could be obtained from the object. The list of Views/Sheets included in that ViewSheetSet was not found there, so this node need not be included in the final graph. It turns out that there is not a node that ships with Dynamo that will generate a list of Views/Sheets that are included in a ViewSheet Set, and I was not able to find one in any of the third-party packages I have installed. I was able to find this thread in the Forum, in which Kulkul posted the Python code needed to extract a list of the Sheets/Views. My adaption of that, shown in the image below, is the code behind the Python Script 1 node, which takes the desired ViewSheetSet object as input and generates a list of the included Views and Sheets as output.

That list of Views and Sheets is then sent to several locations. During development, I added an Element.Name node and two Watch nodes to view the list. These do not need to be part of the final graph, but I left them in as a way to visually check that the correct ViewSheetSet was obtained.

In the next installment, I will cover the nodes that separate the list of Views/Sheets into separate lists of Views and Sheets. I wanted to do this so that I could include the Sheet Number value as part of the name of exported Sheets. Since Views do not have a Sheet Number property, they needed have the name of the exported drawing generated separately.

No comments: