Deleting specific multiple shared parameters in multiple families at once

Hey there,
I’m a newbie to Revit and Dynamo. Is it possible to delete multiple specific shared parameters in multiple families at once? For example: I have many window families in a folder on my computer that all contain the same shared parameters. I now want to remove 2 (as an example) shared parameters from all the window families. Instead of going into each family and removing the parameters manually, is it possible to remove the parameters from all the families at once?
And if that is possible, could I then also add multiple shared parameters to multiple families at once?

1 Like

@alshammary.l ,

here i had a similar topic

https://forum.dynamobim.com/guidelines

1 Like

You can’t edit a family without opening it. You could programmatically open all the families, edit them, and save them, but that is pretty intensive compute wise, as you have to open all the files at once and Revit doesn’t like using that many documents at once.

Why not start a new project with no template, add all of the families and types to the project, delete the shared parameters, and then save out all the families using the “save as library” function?

2 Likes

2022-07-27_15h50_11

Thanks for the reply. Are you suggesting that I open each family manually and delete the shared parameters in them as well? If so, then that is exactly what I’m trying to avoid. The reason I don’t want to do this manually is because this will happen often. The company I work at uses product numbers as shared parameters in their families. So all the window families have the same product number as a shared parameter in them. The problem is that the product number changes from time to time. This doesn’t only happen with the window families, but with all the other types of families as well. So ideally I need to find a way to delete the product number shared parameter in all families at once.
Please correct me if I missunderstood your suggestion.

Try this: Load a family with a shared parameter into a new project started from a template. In that project delete the shared parameter so that the family in the project no longer has a reference to the parameter. Then save as a library to push that family out of the project. Open the family you saved out, and see if the shared parameter is still there.

If that works for you then you’ll just have to run that process for whatever families you want to delete shared parameters from. It’s ~8 steps, but those 8 steps can be run on 10000 families at once, or 1 family.

I just tried that and unfortunately the parameter is still in the families.

As you can see the family still has all 4 test parameters even after I loaded it into a new project with no template, deleted the 3 test shared parameters and saved the family as a library.

Shoot. Thought that would be a simple work around. Sorry. :disappointed:

You’re into the “open each family programmatically” option now. Check out the latest Rhythm package and the Orchid package as one/both of those will be a must if you use nodes.

1 Like

Totally possible from directories, and from project as well (but I’ve shown how to do via directory below - more stable approach in my experience. Most of the Python I’ve used is in my Crumple package but I’ve adjusted it to work one family document at a time, so if it hits any errors/crashes you get the work completed to a point at least.


Delete parameters in directory.dyn (15.9 KB)

# Made by Gavin Crump
# Free for use
# BIM Guru, www.bimguru.com.au

# Boilerplate text
import clr

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager 
from RevitServices.Transactions import TransactionManager 

clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")

import Autodesk 
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *

# Current doc/app/ui
uiapp = DocumentManager.Instance.CurrentUIApplication 
app = uiapp.Application

# Define list/unwrap list functions
def tolist(input):
    result = input if isinstance(input, list) else [input]
    return result

# Preparing input from dynamo to revit
pathList = tolist(IN[0])
paraList = tolist(IN[1])

# Track what happens
results = []

# For each family file path
for path in pathList:
	
	# Open the family, get its name
	doc = app.OpenDocumentFile(path)
	docT = doc.Title
	
	# Get the family manager, and a subresult
	famMan = doc.FamilyManager
	famResult = []
	
	# Start a Revit transaction
	t = Transaction(doc, docT)
	t.Start()
	
	# Get all parameters in the document
	params = famMan.Parameters
	
	# For each parameter
	for param in params:
		
		# Get the parameters name
		p_nam = param.Definition.Name
		
		# If the parameter is in your list of names
		if p_nam in paraList:
			# Try to remove it, else pass
			try:
				famMan.RemoveParameter(param)
				famResult.append(p_nam + " deleted from " + docT)
			except:
				famResult.append(p_nam + " failed to delete from " + docT)
	
	# Finish a Revit transaction
	t.Commit()
	
	# Append the outcome
	results.append(famResult)
	
	# Close and save the document
	doc.Close(True)

# Preparing output to Dynamo
OUT = results
1 Like

No problem! Thank you for your replies.

1 Like

Gavin thank you so much!!! It worked. I’ve been beating my head around this for a couple of days now… Thank you for helping out the community.

2 Likes