Hi,
I am trying to generate DuplictedView WithDetailing and then apply ViewTemplate,
I am struggling with python script,
Would appreciate any help,
Michal
import sys
import clr
from System.Collections.Generic import *
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
import Autodesk
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
References = UnwrapElement(IN[0])
Templates = UnwrapElement(IN[1])
ViewTypeId = References[0].GetTypeId()
DupWithDtl = Autodesk.Revit.DB.ViewDuplicateOption.WithDetailing
TransactionManager.Instance.EnsureInTransaction(doc)
for Reference in References:
LvlId = Reference.GenLevel.Id
ReferenceScopeBox = Reference.GetParameters('Scope Box')[0].AsElementId()
DependentViewsId = Reference.GetDependentViewIds()
if len(DependentViewsId) != 0:
DependentViews = FilteredElementCollector(doc, DependentViewsId)
DepScopeBoxes = []
for DependentView in DependentViews:
DepScopeBoxes.append(DependentView.GetParameters('Scope Box')[0].AsElementId())
for Template in Templates:
NewView = View.Duplicate(Reference, DupWithDtl)
NewView.ViewTemplateId = Template.Id
NewView.ApplyViewTemplateParameters(Reference)
NewView.Name = str(Reference.GenLevel.Name) + '_' + str(Template.Name)
NewView.GetParameters('Scope Box')[0].Set(ReferenceScopeBox)
NewView.GetParameters('Scope Box')[1].Set(ReferenceScopeBox)
if len(DependentViewsId) != 0:
for DepScopeBox in DepScopeBoxes:
NewViewDep = NewView.Duplicate(AsDependent)
NewViewDep.GetParameters('Scope Box')[0].Set(DepScopeBox)
NewViewDep.GetParameters('Scope Box')[1].Set(DepScopeBox)
TransactionManager.Instance.TransactionTaskDone()
OUT = References