Sad news, thanks to Alex S. I ran into what appears to be a by-design limitation in Dynamo.
The idea was to duplicate a Legend View since it is not possible to create a new one from the API, rename the copy and use it to set the Active View property of the UIDocument.
Turns out it's not possible to do that in Dynamo, for now.
Here's the Python script I've used, maybe someone has already found a solution to that.
Try putting the end transaction before setting the active view. If you look at the API documentation, "The active view can only be changed when: There is no open transaction." Hope it helps.
RispondiElimina