How to add brackets in a list

Hi everybody,

I would like to say thank you in advance. I am new user in Dynamo and this page is being really useful to enter in this huge world. I have been working with revit several year but I didn’t need it until a few months ago.

My question is quite simple, I have done a script to fill automatically a text parameter called H that we use to annotate the special height of some elements, this value comes directly from another parameter called AFFL that is filled in revit.

At this point everything is clear, I used the node string to object to transform the value into a string to fill the text parameter. The problem appear when I have to add brackets above and behind of each number (It is the representation of the company for special heights)

In the pic it is seen the list of heights (without brackets) on the left and how the numbers should be on the right. For example, instead of 200 it should be [200]

I am almost sure it is a problem about lists but I don’t know how to face it.

Thank you

Hi, and welcome to the lovely world named Dynamo!

so … you want ALL numbers listed in the String.Replace node to get [ number ] ?

if so:

Connect the str output of String.Replace to string1 of String.Concat

or lazy version:
Capture

1 Like

Hi 3Pinter,

Thank you very much! Yes it is what I was looking for :wink:

The only problem that I have now is to remove the brackets from the empty places of the list. Do you know how can I do it?
Thank you in advance

You can see what I mean in the pic

1 Like

Hi!

I tried that but something didn’t work, brackets are still there :frowning:

Thank you

(this was made in version 1.3x, in version 2.x change “{…}” to “[…]”

2 Likes

I’m likely not as good as 3Pinter at Dynamo, my understanding of Code Block’s is limited. However i see two alternative means to get around the issue of the “” within the empty value fields.

you could use String Replace to remove the added square brackets where the value is blank…

image

Alternatively you could use “==” node along with the “if” node…

image