Hi,
I’m new to Dynamo and Python, so bear with me.
I’m following Aussie Bim Guru’s “Bulk replace Revit family parameters using Dynamo!” video, and I’ve gotten to the last script, but I’m stuck. In my code when I start the transaction (2 lines down from the first for loop), Dynamo throws me an error:
TypeError: No constructor matches given arguments: (<class ‘Revit.Application.FamilyDocument’>, <class ‘str’>) [’ File “”, line 30, in \n’]
I’m thinking that it’s because I’m supplying a FamilyDocument into the input, not a Document. Is this correct? Can transactions only be instantiated in a Document? How would I go about getting the Document from a FamilyDocument?
Thanks in advance for all your help
# Boilerplate text
import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
# unwrap all elements to use with API
doc = IN[0]
param_list = IN[1]
def_list = IN[2]
param_lists_out = []
counter = 0
# Main body of code
param_list_out = []
for p,d in zip(param_list,def_list):
# start a transaction
trans = Transaction(doc,'Replace parameters')
trans.Start()
# Set the counter for namin parameters
counter += 1
strCount = str(counter)
tempName = "Temporary " + strCount
# Get family manager and parameter settings
fm = doc.FamilyManager
pg = p.Definition.ParameterGroup
pi = p.Instance
# If parameter is shared, replace with family
# If not, then we rename it anyway
if p.IsShared:
p = fm.ReplaceParameter(p, tempName, pg, pi)
else:
fm.RenameParameter(p, tempName)
# Replace family parameter with shared parameter
shp = fm.ReplaceParameter(p, d, pg, pi)
param_list_out.append(shp)
# Close the transaction
trans.Commit()
TransactionManager.Instance.ForceCloseTransaction()
param_lists_out.append(param_list_out)
# Output and Changing element to Dynamo for export
# <element>.ToDSType(True), #Not created in script, mark as Revit-owned
# <element>.ToDSType(False) #Created in script, mark as non-Revit-owned
# Preparing output to Dynamo
OUT = [param_lists_out,doc]