So, this came from a twitter query… if we wanted to check which families contain an Instance Parameter & that family is not placed…
Is it possible to check without placing then deleting every family in the project?!
Here’s a graph and some test files I’ve been playing with, you can see that I am correctly returning the Type Parameter exists, but incorrectly returning that the Instance Parameter doesn’t exist.
In the same way that a family instance does not have access to type properties, a family type does not have access to instance properties. I think your only other option is to open the family document and check the parameter list there.
But it’s a niggle… Obviously we do see these in Revit… when I get in the office tomorrow I’ll have a play with Parameter Maps… it does seem to be operating in a Family class rather than a Type class… It says All Parameters…
#thanks everyone for their help!
import clr
import sys
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
import System
den = UnwrapElement(IN[0])
dln = []
output = []
for d in den:
dln.append(d.GetOrderedParameters())
for dl in dln:
paramNames = []
for l in dl:
paramNames.append(l.Definition.Name)
output.append(paramNames)
OUT = output
I guess my first question is how are you searching for families that aren’t placed? After that, once you get the families you want, as @Nick_Boyts said the next step I would do is open the family, check each parameter if it is instance, and then close the family but I could see this getting resource intensive depending on the model size.
But then this gets harder because all families have instance parameters like base level or offset or mark, etc. and I am not sure if these would show up in your checking.
But yes, I was hoping when the documentation said ‘all parameters’ it meant through the sub-classes, but it doesn’t… So I just get the parameters directly available to a family, e.g. Shared, Hosted (or I get the Type parameters if I run it on a Type).
#thanks everyone for their help!
import clr
import sys
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
import System
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
fams = UnwrapElement(IN[0])
famParams = []
output = []
for fam in fams:
if fam.IsEditable:
familyDoc = doc.EditFamily(fam)
familyMan = familyDoc.FamilyManager
familyPar = familyMan.GetParameters()
famParams.append(familyPar)
TransactionManager.Instance.ForceCloseTransaction()
save = False
familyDoc.Close(save)
else:
famParams.append('Not Editable')
for famParam in famParams:
paramNames = []
try:
for famPm in famParam:
paramNames.append(famPm.Definition.Name)
except:
paramNames.append('Not Editable')
output.append(paramNames)
OUT = output
Still needs some work, but the principle is there… basically background opening the family from within the active document, that gives access to the family manager, then you can get all parameters
Cheers,
Mark
Edit: Thanks @john_pierson for noting that I need to close the families after editing
No… if you see my screen grab, ‘test’ is a Type and ‘test int’ is an Instance…
It is basically automatically opening the family from inside the project, reading the dialogue you get when you hit the blue squares, then closing the family again…
Um, I am pretty sure you need to close out the document. If I am not mistaken, EditFamily essentially opens the document in memory.
@Kulku, A simple test is to, run your workflow l, then go to Manage>Transfer Project Standards and see if there are any families open that were not before.