I am trying to create dynamo to delete unwanted project parameters from revit model.
I have prepared below dynamo script, but it is not working.
Could you please help me?
# dynamo version - 1.3.2
#(should be fine with 1.3.x or 2.x.x versions too)
import clr
clr.AddReference('RevitAPI')
clr.AddReference("RevitServices")
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
# input[0]
elements = IN[0]
# params id
todelete = []
# check/make list
if not isinstance(elements, list):
elements = [elements]
# collect parameters
parameters = FilteredElementCollector(doc).OfClass(ParameterElement).ToElements()
# loop input params
for elem in elements:
# loop existing params
for param in parameters:
# if name found
if param.Name == elem:
# append id to delete list
todelete.append(param.Id)
# start transaction
TransactionManager.Instance.EnsureInTransaction(doc)
# delete from document
res = [doc.Delete(i) for i in todelete]
# end transaction
TransactionManager.Instance.TransactionTaskDone()
OUT = res
@nileshkatkar1983in, you are having Revit API Class (ParameterElement) Importing Error,so here is updated version (another way of importing classes)remove-project-parameters.dyn (2.7 KB)
. Try this one and let’s see if Ok or not.