I’m currently working on a python script within Dynamo that will batch load families . It works as is in IronPython ; however, when I switch to CPython I get a TypeError : interface takes exactly one argument line 58 (the famDoc.LoadFamily(doc,FamilyOption()) line). It appears to be related to the FamilyOption Class, but can’t seem to figure out how to fix it. Any thoughts?
class FamilyOption(IFamilyLoadOptions):
def OnFamilyFound(self, familyInUse, overwriteParameterValues):
overwriteParameterValues = True
return True
def OnSharedFamilyFound(self, sharedFamily, familyInUse, source, overwriteParameterValues):
overwriteParameterValues = True
return True
def ChangeCategory(doc, element, bic):
# Retrieve the family from the given element
family = element.Symbol.Family
TransactionManager.Instance.ForceCloseTransaction()
famDoc = doc.EditFamily(family)
ownerFamily = famDoc.OwnerFamily
# Change the category of the owner family to a new category, in this case, Windows
ownerFamily.FamilyCategory = Category.GetCategory(famDoc, bic)
# Define new subcategories to be added to the family
newSubCats = ["Glass", "Trim", "Frame/Mullion", "Sill/Head", "Panel"]
TransactionManager.Instance.EnsureInTransaction(famDoc)
subCats = ownerFamily.FamilyCategory.SubCategories
subCatDict = {}
for s in subCats:
subCatDict[s.Name] = s
for w in newSubCats:
# Add new subcategory if it does not already exist
if w not in subCatDict:
try:
newCat = famDoc.Settings.Categories.NewSubcategory(ownerFamily.FamilyCategory, w)
except: pass
TransactionManager.Instance.TransactionTaskDone()
# Start a new transaction in the main document to load the modified family
TransactionManager.Instance.EnsureInTransaction(doc)
famDoc.LoadFamily(doc, FamilyOption())
TransactionManager.Instance.TransactionTaskDone()
return ownerFamily