Create View Types - none to duplicate

Hi,

See if this code helps? (based on work by @Ron_Allen) I think there must be the inbuilt types, so you can duplicate one of those…

Cheers,

Mark

image

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

# The inputs to this node will be stored as a list in the IN variables.
strVIEW_TYPE_Name  = IN[0]
strNew_VIEW_TYPE_Name = IN[1]


# Place your code below this line
fec_ViewFamilyType = FilteredElementCollector(doc).OfClass(ViewFamilyType)


view_Type_List = []
for viewFamilyType in fec_ViewFamilyType:
    name = doc.GetElement(viewFamilyType.Id).get_Parameter(BuiltInParameter.ALL_MODEL_TYPE_NAME).AsString()
    if name == strVIEW_TYPE_Name:
        view_Type_List.append(viewFamilyType)

TransactionManager.Instance.EnsureInTransaction(doc)
new_v  = view_Type_List[0].Duplicate(strNew_VIEW_TYPE_Name)
TransactionManager.Instance.TransactionTaskDone()

# Assign your output to the OUT variable.
OUT = new_v