Recreate section box in an existing view

I’ve created a script that creates a section box in a new view around selected elements of a linked file. See

Thanks to @Einar_Raknes in this post:

Now I’m stuck because when I run this script again a new view is created automatically because the view in my script already exist and in that new view there is no section box.

How can I modify my script so that the section box is recreated in that existing view?