As I was updating existing templates and building some new ones, I wanted a better way to determine what fonts/text styles are in use and where they are being used.
Exploring some existing dynamo graphs and custom nodes, I put the following graph together.
This graph searches the current project, builds a list of graphic views (plan, section, elevation, drafting, legend, and callout) and then builds a list of elements in those views.
The data is then output to an excel file for review. Here is what the output looks like. As you can see, the graph outputs the textnote style and the viewname the text element was found in.
For those of you who want to do it yourself and understand how I reached the working version of the graph, follow along as I describe how I created the graph.
First Step – Insert the White_Dynamo_Graphic_Standard node, edit the custom node and copy all the precreated groups, pasting them into your new home workspace. I edited the file notes contained inside this standard and saved it so I have a ready to use set of groups whenever I need them.
Since we are trying to determine where standard elements are being used in projects and templates, and I know I want to be able to reuse the data in excel, lets get started with the beginning and end in mind. Type excel into the search tool in the Dynamo graph editor and add the Excel.WriteToFile node. This node presents a number of connectors helping us to quickly add the necessary inputs by search.
Add a File Path node, a Categories node, and a Boolean node as we will be able to quickly connect these up as we begin to think through the logic of what the rest of the graph will require. I prefer the the file path node to a string based input, because I can select an excel file by browsing to it. The categories node allows us to select the category to be reviewed (Text Notes). I will add a “String from Object” node and connect it to the Categories node, so I pass in the sheet name directly from my chosen category. The boolean node lets us control whether the data is refreshed and whether the excel file is overwritten. I know that I want to start filling the excel file from column A and Row 1, so I’ll add a code block by double clicking in the editor and preparing to pass out a value of zero. I will connect up the nodes like this:
As you can see in the image above, I have already provided 5 out of the six input nodes required by the Excel.WriteToFile node. So now we tackle the data input. Since I want to figure out where all my text note styles are being used, so I can standardize the text note styles, I’ll next add the Document.Views node from the clockworks package to generate a list of all views contained in the current project. Click on your Excel.WriteToFile node, right click your mouse and freeze this node til we have the data input prepared. Click run to see the output from the Document.Views node.
I added and connected the Lunchbox node: Remove Null Values to the output of the Document.Views node, because I saw some null output after running it the first time. Looking at the list of views provided, I realized that there were many views that would not be of use to me in this process, so I searched for a node that could give me a way to filter out these nodes. Having found no such node, I decided to modify the View.IsTemplateView node from Clockwork for my use. The easiest way, I’ve found is to simply add this node to your graph, then select it and right click choosing to “Edit custom node”. Once the node is open in the editor, copy all the internal nodes to the clipboard and then close the View.IsTemplateView node. Remove it from your graph and click “File” new custom node. When the editor opens, paste the contents of the clipboard to your new custom node. It should look like the following image:
I named my custom node: View.IsGraphicView and added it to the BesideTheCursor Package, I’ll publish it later tonight or tomorrow. In the mean time, you can do what I did and modify the python script as shown in the image below. I added some exclusions of view types to exclude. This results in a view filter that effectively rips out the views that wouldn’t contain graphics.
I modified the original python code very slightly, see the difference view image below:
I used a boolean if else line to accomplish what i needed as seen in the images above. A quick run of the partially completed graphs shows that I am now effectively identifying the views that I do not wish to process. I can use the true false output from my new custom node with the List.FilterByBoolMask to filter out the view types I no longer want to include. I connect my node to the bool input and connect the cleaned output to the list input on the List.FilterByBoolMask node.
I am now ready to pass my list of included views into the Springs.ElementsFromViews node, to begin building the list of elements found in every view. A quick run at this time reveals many thousands of elements. Don’t get worried by the spinning blue wheel. It will run to completion rather quickly.
Now its time to filter for the type of element I’m looking for. We can add a code block and type in the TypeName description for TextNotes. You can see what is required from the Object.Type node. We connect this into the String.Contains node to search our large element list and build a boolean list of true and false. Connect these up to a List.FilterByBoolMask and then flatten the output will complete our data filtering down to just TextNotes as shown below.
Lets add some more nodes. Add Element.OwnerView, Element.Name (Universal), TextNote.Typename and we’ll connect them up and build a new list using List.Create with two input connectors as shown below:
Lets run this graph and take a look at the output from our list to this point. As can be seen in the image below, we are getting two sublists; the first contains the viewnames and the second list contains the textnote typenames. Having worked with the Excel.WriteToFile node in the past, I know from experience that the data input node prefers lists that contain rows and columnar data. Lets add the List.Transpose node to convert our list to this format and connect it into the Excel.WriteToFile data input connector. Now its time to run the graph, so unfreeze the final node and get ready to review your list of textnotes used by view. You can grab a copy of the graph here:, but its always best to build it yourself to gain a better understanding of how Dynamo works.
During the process of writing this blog post, I realized that the path I took was longer than necessary and can actually be accomplished without the custom node created, but what fun would that be? Check back later for an update and a simpler graph to complete the same workflow.