I’m trying to change a script that configures a family to operate from a project document instead of a family document. Also trying to learn the family document and FamilyManager interactions. Specific context: building a key plan family with area visibility parameters
part of this is adding some family parameters. when i call AddParameter i’m trying to use the ForgeTypeIds as indicated in the 2022 API docs, but get this error
TypeError: expected BuiltInParameterGroup, got ForgeTypeId
Am i misreading something here?
#create a new family document given a name and file path
import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('RevitNodes')
import Revit
clr.AddReference('DSCoreNodes')
import DSCore
from DSCore import Color
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
#functions
def BuildVisParamName (name):
modified_string = name.replace(" ", "_")
modified_string = "Show" + modified_string
return modified_string
def BuildTextNoteValue (name):
modified_string = name.split(" ")
return modified_string[0]
def CreateAreaType(name):
return name
#inputs
fDoc = IN[0]
regionNames = IN[1]
regionCurves = IN[2]
trace = []
savOp = SaveAsOptions()
fMan = fDoc.FamilyManager
parameter_type = ForgeTypeId()
#
viewCategoryFilter = ElementCategoryFilter(BuiltInCategory.OST_Views)
fDocViews = FilteredElementCollector(fDoc).WherePasses(viewCategoryFilter).OfClass(View).ToElementIds()
trace.append("x- views"+str(len(fDocViews)))
fTran = Transaction(fDoc)
fTran.Start("-configure family-")
sTran = SubTransaction(fDoc)
sTran.Start()
trace.append("-create type: None")
fMan.NewType("None")
trace.append("-create type: Overall")
fMan.NewType("Overall")
trace.append("-create parameter: ShowBorder")
#collect fDoc views (should be one)
for n,b in zip(regionNames,regionCurves):
trace.append("-create type: "+n)
fMan.NewType(n)
fMan.AddParameter(BuildVisParamName(n),GroupTypeId.Graphics,SpecTypeId.Boolean,False)
trace.append("-create parameter: "+ BuildVisParamName(n))
types = fMan.Types
params = fMan.Parameters
# set default parameters
for t in types:
trace.append(str(type(t)))
sTran.Commit()
sTran.Dispose()
fTran.Commit()
fTran.Dispose()
#fDoc.SaveAs(filePathString)
#fDoc.Close()
OUT = fDoc,trace