Appending list by adding unique identifier to duplicate values

Hi all,

I’m a long time lurker, and this forum has been fundamental to getting me into Dynamo. Thank you to all who participate.

I’m creating a script to label all my interior elevations once created with the room number and orientation, i.e. 101N. I thought I had it until I realized that my list of view names has the possibility of duplicates, and, as we all know, no duplicate view names.

Normally I can power through an issue like this, but I’m having trouble even conceptualizing how to solve this. What I need is: I have a list of values (room names) [101N, 101E, 101S…110N…] but for any duplicates, I need to append my list from [101N, 101N, 101N, 101E, 101S] to [101N, 101N_1, 101N_2, 101E, 101S]. Some obvious constraints- I need the list to remain the same length, and it has to stay in the same order.

I can’t figure out how to step through a list and append duplicate values by adding a unique identifier (_1, _2). Any advice would be greatly appreciated. Thanks again to the forum as a whole!!

Is your parameter for [101N, 101S… etc] is “Name” in the properties?

I’m ultimately feeding this into ‘Element.SetParameterByName’ with ‘element’ being my list of views and ‘parameterName’ being “View Name”. Hope that helps. :grimacing:

hi,

something like this duplicate_room_names.dyn (6.2 KB)


Oh my gosh!!!

I’m pulling my hair out because you’ve nailed the result I want but I cant figure out how you got it!!

Would it help to say that what I would like to feed into the Python script is a full list of names, as strings (101N, 101N, 101E) and a list of (I’m assuming) list of unique names(also strings)?? (101N, 101E), with the output being as you’ve already achieved (101N, 101N_1, 101E)??

Thank you so much for your time already. Truly appreciative!! :pray:

Please dont forget to mark my post as the solution to your problem. :slight_smile:

I will have my lunch, please wait a minute

Here is your second request duplicate_names.dyn (3.6 KB)

Both humbled, and irritated I am not at this level of coding. Thank you so much for your help.

Last question- is it possible to maintain original list order? As to match ‘views’ with the names I am feeding into ‘SetParameterByName’? It appears your script is alphabetizing the results…

please check this duplicate_room_names.dyn (9.1 KB)

1 Like

I already solve your 3 requests.

I’m trying desperately to make your Python script match what I’ve got, but I’m having trouble matching your IN[0] and IN[1] variables, or lists. I see you are inputting as rooms, but I am trying to input as strings.

I am currently trying to make what you have provided work to achieve my goal.



roomNumbers.dyn (21.9 KB)

2 Likes

please check this duplicate_room_names.dyn (7.5 KB)

6

put in IN[0] your rooms, in IN[1] your strings and in IN[2] the parameter where the name resides.

1 Like

I’m not sure how we got spun out on changing room names-

I am trying to rename views, but at it’s core, I have a list of string values, [101N, 101N, 101N, 101E, 101S] that I am trying to append to [101N, 101N_1, 101N_2, 101E, 101S].

Contained within the help provided, I can probably figure it out, but I’m having a hard time reverse engineering the Rooms back strings. Bare with me :man_facepalming:, and again, I am super appreciative of any help, thank you!!!


viewNames.dyn (29.5 KB)

2 Likes

Vikram,

Absolutely thrilled to have you respond. Any time I am searching for a solution and see your responses, I know I’m getting closer!!

This did it. I will clean up and post a full .dyn to help others. Thank you for helping me through this final hurdle today!! You are a magician!

1 Like

hi try this duplicate_names.dyn (3.8 KB)

7

1 Like

Thank you very much for helping. It was my undoing that I could not follow your Python.

Thank you again, I am very thankful for your time and help.

Ok no problem. Sorry I cannot figure out what you want to do.