Duplicate multiple selected views

Hey,

I am very new to Dynamo but I am trying to create a script that would duplicate multiple views that I select in the project browser…

I came up with something and it partially works but what it does is that if I select all 4 views every one of them gets duplicated not once but 4 times… If I select only 3 of the views its the same only every one of the selected views gets duplicated 3 times

What I am trying to achieve is to duplicate every one of those views but only 1 time, any ideas what I am doing wrong?

As I new member I had to put all pictures in one so below you can see what I am describing above and the script I came up with:

Try setting the list level to @L1 and the lacing to shortest for the Duplicate Element node.

1 Like

Thank you very much… setting the lacing to shortest actually resolved the issue

One more thing I am now facing is that when the views are duplicated they get renamed…

you can see already in the first picure I posted the view is called “Wandaanzicht AS A” and the duplicate gets renamed to “Wandaanzicht AS A1” is there a way to keep the original name but maybe add “Copy1” behind it so that the original name is kept?

so it would be named “Wandaanzicht AS A Copy1”

Duplication sets the name automatically,. and while the name is a bit cumbersome it’s definitely easier than making a new view from scratch and recreating all the other stuff in the old view… As such I’d duplicate the view and then rename it. Name is a parameter for views if I recall, so you can use Element.GetParameterValueByName to get the newly created names, String.SubString to remove the last character from the name, + to add the new prefix to the end of the string, and Element.SetParameterValueByName to set the view’s name to the revised string. Note that if you do this and run the graph twice you’re going to get some errors, so you might want to add some additional error handling along the way.

1 Like