Hi ,
I want to Create many new door Types by given varies door types and specific door names, I know there is a node called “ElementType.Duplicate” in Sprins Package, but i want to use the NewType() method to write my code,to make things simple, I write a test code. Everything runs well until i add the code “familyManager.NewType(doorName)” ,the exception is shown in the pic.
can anyone help me out? any suggestion will be appreciated.
NewDoorType.dyn (4.9 KB)
import clr
clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *
import os
import Autodesk.Revit.DB
from Autodesk.Revit.DB import IFamilyLoadOptions
import sys
import System
pyt_path = r’C:\Program Files (x86)\IronPython 2.7\Lib’
sys.path.append(pyt_path)
import os
from os import path
Import DocumentManager and TransactionManager
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
#Import ToDSType(bool) extension method
clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
def EditFamilyTypes(document,familySymbolInput,doorName):
TransactionManager.Instance.ForceCloseTransaction()
if None == document or None == familySymbolInput:
return
family = familySymbolInput.Family
familyDoc = document.EditFamily(family)
familyManager = familyDoc.FamilyManager
familyTypes = familyManager.Types
familyTypesItor = familyTypes.ForwardIterator()
familyTypesItor.Reset()
types =
bl =
newTypes =
while familyTypesItor.MoveNext():
familyType = familyTypesItor.Current
types.append(familyType)
for type in types:
if type.Name != doorName:
# bl.append("True")
newTypes.append(familyManager.NewType(doorName))
return newTypes
#Unwrap
doorType = UnwrapElement(IN[0])
doorName = UnwrapElement(IN[1])
#Start Transaction
doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)
#=============================================================================================
newDoorType = EditFamilyTypes(doc,doorType,doorName)
#End Transaction
TransactionManager.Instance.TransactionTaskDone()
#=============================================================================================
OUT = newDoorType