∴Triple Zero Labs

Combine Multiple Text Notes with Dynamo

I was recently asked to convert several AutoCAD DWGs to Drafting Views in Revit.

One issue that I came across frequently during this project were Text Notes which were Multiline Text in AutoCAD were separated in individual single-line Text Notes in Revit once exploded. At first I painfully combined these lines of text into a single Text Note manually by copy-and-pasting each line, but not after long I asked myself, “can automate this with Dynamo?”

Lo and behold, Dynamo was able to save me lots of time (and sanity).

Download The Script

The Dynamo graph can be found in our Dynamo repository on GitHub or by clicking on the link below.

CombineTextNotes.dyn (50 downloads )

How to Use

Open Dynamo Player and navigate to the CombineTextNotes.dyn file and click the Edit Inputs icon.

You will then be prompted to select model elements. Click the Select button.

Return to Revit and select all text notes that need to be combined. Note the selected Element IDs are available to be displayed. Click the Play button to run the script.

Return to Revit and find the long text note which was added by the Dynamo script.

Simply adjust the width of the text note and double check that the Text Notes were combined correctly.

How does it work?

Select Elements

The first node in the graph is the only input which allows the user to select multiple elements in the model.

Filter Unwanted Elements

The second group of nodes filters out any Elements which are not of the Text Notes Category.

You may have noticed that I am converting the names of the Categories to Strings to compare them for the List.FilterByBoolMask node. For some reason, Dynamo couldn’t compare the Category objects themselves, but converting the names to Strings seemed to work. Free free to drop me a comment if you know why this might not be working and I’ll update the graph!

Create a Single String

The List.FilterByBoolMask node returns a List of Strings which we need to trim the whitespace (leading or trailing spaces) before finally using a Python script to combine the list of Strings into a single String.

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

strings_in = IN[0]
string_out = ''

for s in strings_in:
	string_out += s + ' '

# Assign your output to the OUT variable.
OUT = string_out

If you’re not experienced in Python, this can serve as a simple example of looping through a List (strings_in) and appending a String (string_out) with each item (s) in the List.

Create the Text Note

Creating the new Text Note is simple using the TextNote.ByLocation node, however the insertion point proved to be poor UX if a coordinate was hardcoded. Sometimes the new Text Note would appear somewhere off in space, making it difficult to find (speaking from experience). To solve for this, we take the first Text Note from the selected simply to get the coordinates. This does place the new Text Note on top of the original text, however at least it is on screen for the user to see immediately and adjust as needed.

Conclusion

I hope this simple script helps someone out there who finds themselves painfully combining Text Notes. If you’re having issues or have suggestions on how this can be improved, create an issue on GitHub or drop me a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *