Dynamo for Revit Basics – Part 2 of 4: Working with Text...

5
[email protected] www.imaginit.com 800.356.9050 TECHNICAL WHITEPAPER Dynamo for Revit Basics – Part 2 of 4: Working with Text (Strings) When starting with Autodesk® Dynamo, it is hard to determine where to begin. In the first part of this series, we discussed the basics of Dynamo and how to do some basic interaction with the software. Now we will look at one of the most commonly used variables, which is a String (otherwise known as Text). Strings control a large amount of text parameters and are a key component when dealing with data collaboration outside of the Autodesk® Revit® software. Knowing how to manipulate and organize strings is very important. Let’s open up the Dynamo add-in within Revit and see how to make strings work for us! Basic String Input There are 2 basic methods of inputting string values. The first of which is using the ‘String’ node. This node requires case sensitive text input. The second method is via a Code Block. This node requires you to place the intended text in quotation marks; this is how Dynamo reads variables as text. Code blocks tend to be faster because it only requires you to double-click on the screen to place a code block. Table of Contents Basic String Input Concatenation Concatenate by Separator Concatenate by List & Separator Concatenate by Code Block String Insertion String Length String Occurrence Count String Case Change

Transcript of Dynamo for Revit Basics – Part 2 of 4: Working with Text...

Page 1: Dynamo for Revit Basics – Part 2 of 4: Working with Text ...portal.imaginit.com/Portals/0/whitepapers/Dynamo_for_Revit_Basics2.pdf · Dynamo for Revit Basics – Part 2 of 4: Working

[email protected] www.imaginit.com800.356.9050

TECHNICAL WHITEPAPER

Dynamo for Revit Basics – Part 2 of 4: Working with Text (Strings)

When starting with Autodesk® Dynamo, it is hard to determine where to begin. In the first part of this series, we discussed the basics of Dynamo and how to do some basic interaction with the software. Now we will look at one of the most commonly used variables, which is a String (otherwise known as Text). Strings control a large amount of text parameters and are a key component when dealing with data collaboration outside of the Autodesk® Revit® software. Knowing how to manipulate and organize strings is very important. Let’s open up the Dynamo add-in within Revit and see how to make strings work for us!

Basic String Input

There are 2 basic methods of inputting string values. The first of which is using the ‘String’ node. This node requires case sensitive text input. The second method is via a Code Block. This node requires you to place the intended text in quotation marks; this is how Dynamo reads variables as text.

Code blocks tend to be faster because it only requires you to double-click on the screen to place a code block.

Table of Contents

■ Basic String Input

■ Concatenation

■ Concatenate by Separator

■ Concatenate by List & Separator

■ Concatenate by Code Block

■ String Insertion

■ String Length

■ String Occurrence Count

■ String Case Change

Page 2: Dynamo for Revit Basics – Part 2 of 4: Working with Text ...portal.imaginit.com/Portals/0/whitepapers/Dynamo_for_Revit_Basics2.pdf · Dynamo for Revit Basics – Part 2 of 4: Working

Dynamo for Revit Basics – Part 2 of 4: Working with Text (Strings) 2

[email protected] www.imaginit.com800.356.9050

Concatenation

Concatenation is a method used to combine variables such as text. The String.Concat node combines separate string values into one continuous string. Think of it as a simple addition formula. Please note: Spaces are considered to be characters. If you require spaces, please ensure that it is added onto the beginning or end of your string.

Concatenate by Separator

Sometimes it is beneficial to use a standard separator for separating strings. In the examples on the right, a “_” is being used to separate each string. This can prove to be useful when combining Room Numbers with Room Names for use in an Excel schedule or Room data sheet.

Page 3: Dynamo for Revit Basics – Part 2 of 4: Working with Text ...portal.imaginit.com/Portals/0/whitepapers/Dynamo_for_Revit_Basics2.pdf · Dynamo for Revit Basics – Part 2 of 4: Working

Dynamo for Revit Basics – Part 2 of 4: Working with Text (Strings) 3

[email protected] www.imaginit.com800.356.9050

Concatenate by List & Separator

Concatenating a few pieces of text may seem a little rudimentary. However with the method below, you can concatenate entire lists of strings in sentences. This allows you to add a separator to entire lists of strings and combine them all into one continuous piece of text.

Concatenate by Code Block

As mentioned previously, concatenation is much like addition. String concatenation can be done with a code block by using the “+” symbol for addition. Ensure that all intended characters are enclosed via quotation marks.

Page 4: Dynamo for Revit Basics – Part 2 of 4: Working with Text ...portal.imaginit.com/Portals/0/whitepapers/Dynamo_for_Revit_Basics2.pdf · Dynamo for Revit Basics – Part 2 of 4: Working

Dynamo for Revit Basics – Part 2 of 4: Working with Text (Strings) 4

[email protected] www.imaginit.com800.356.9050

String Insertion

Sometimes strings need to be inserted at certain points within another string. This node allows the user to insert any string at a specific location. This insertion of this text starts at 0 (zero). In the example on the right, the String “n’t” is added to the position where the 3rd character would normally exist. This position is the number 2 (0,1,2) in Dynamo.

String Length

String length is used to extract the number of characters within a string. This can be beneficial when telling Dynamo to only use Strings that have a max of 3 characters. This is a great filtering tool for wall and door schedules.

Page 5: Dynamo for Revit Basics – Part 2 of 4: Working with Text ...portal.imaginit.com/Portals/0/whitepapers/Dynamo_for_Revit_Basics2.pdf · Dynamo for Revit Basics – Part 2 of 4: Working

Dynamo for Revit Basics – Part 2 of 4: Working with Text (Strings) 5

[email protected] www.imaginit.com800.356.9050

About IMAGINiT TechnologiesIMAGINiT Technologies, a Rand Worldwide Company, is a leading provider of enterprise solutions to the engineering community, including the building, manufacturing, civil and mapping industries. With over 25 years of experience, and over 40 offices throughout North America, we provide the expertise, training and support to help companies realize the full power of design technology, maximize ROI and gain competitive advantage.

IMAGINiT is a leading provider of Autodesk software solutions and the largest North American Autodesk Authorized Training Center (ATC) partner. All of our locations are supported by a vast pool of engineering resources focused on developing real-life business solutions for their local clients.

String Occurrence Count

The tool to the right can be used to count the number of specific strings within a large string collection. This is more of an adminis-trative tool to identify over-use and repitition. The boolean is used if the node should be case sensitive.

String Case Change

The tool to the right is a great tool for changing text from a random case to either Upper or Lower case. The boolean attached to the node will switch it to upper case when True or lower when False.

There are many other methods for editing strings within Dynamo, which are fairly self-explanatory. The ones listed above are the most heavily used and most practical for project use. Use this as a guide for editing and manipulating strings when populating scripts. This will prove useful in the next installment of Dynamo for Revit Basics, where we learn how to Extract and Write data to and from Excel. Stay tuned for a more in-depth look into the world of Dynamo!