Duplicate 3D view and set template

Hey.
I want to copy a 3D view 7 times and put the same view template. But i can’t find a way to find my 3D view template.
So far i got this.
Udklip

Solved it

It’s good practice to show your solution.

A ‘solved it’ won’t help others with the same challenge :wink:

7 Likes

Hi @1065553 Nichlas,

Could you share your solution please?

That is actually really close to what I m looking for

Thanks,

Arthur

@1065553 Hey there, I’m also curious of your solution

There’s probably loads of ways to do this depending on where you are starting, but here is an example:

Edit: Ah yes… 3D view templates are still not accessible via the API :-S. Common ADSK! But hey, if you apply your view template to the 3D-view before you duplicate it, all the duplicates should have it applied as well :slight_smile:

1 Like

Think we can apply a plan viewtemplate and should work

1 Like

Ah ok.

I just remembered that there was something funny going on with 3D view templates :slight_smile:

1 Like

Yes Martin…a really old funny thing :wink: so i just look forward how @1065553 handle it, since we had a solution here

Haha, yeah :slight_smile:

But yeah, it’s defin doable :slight_smile:

1 Like

Yes it is…here is another way…

2 Likes

Nice! :slight_smile:

Here’s my original answer with the setting of the VT incorporated:

import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument

#---###Start scripting here:###---#
views = UnwrapElement(IN[0])
vt_Name = IN[1]

fec = FilteredElementCollector(doc).OfClass(View).ToElements()

vt = None
for i in fec:
	if i.IsTemplate and i.Name == vt_Name:
		vt=i

#Transaction start:
TransactionManager.Instance.EnsureInTransaction(doc)
for i in views:
	i.ViewTemplateId = vt.Id
#Transaction end:
TransactionManager.Instance.TransactionTaskDone()

OUT = views
2 Likes