"In computer programming, a string is traditionally a sequence of characters…"
Reference: https://en.wikipedia.org/wiki/String_(computer_science)

In laymen’s terms, a string is basically “text”. It is equivalent to the “Text” type in Revit and the “Text” type in Excel. It can contain letters, numbers, and symbols. Though because strings are not specfically "numbers", they cannot be used in calculations. They are simply the characters themselves displayed on screen.

Defining strings in Dynamo graphs, also called scripts, is a very common thing to do. For example, text is used to get the name of the parameter in Revit that you would like to control. It can also be used rename elements in Revit, and add data to parameters.

To define a string, you can use the Code Block node. Simply use quotations around your text in the Code Block. The quotations are a special code that says any characters inside are considered text and not numbers or parameters or any otheform of coding. This is considered the quickest way to define text in Dynamo and is used very often for targeting parameters in Revit. Double click the canvas to create a code block.

dynamo-now-basics-string-2-code-block

dynamo-now-basics-string-3-code-block

Be aware that more often times than not numbers are defined without the quotations. For example, Element IDs are numbers. Dynamo list indexes are numbers. As you use Dynamo more, it will become more apparent when specific situations require quotations for numbers.

Aside from the Code Block node, you can also use a String node. The String node tends to be easier to understand for beginners, and in general is clearer for the next user to understand that the node is purely for text and nothing else. Type in “string” in the search bar to retrieve the String node.

dynamo-now-basics-string-1

There are other nodes that may also allow you to define Strings in Dynamo but the above two are the most common.


0 Comments

Leave a Reply

Avatar placeholder