Add Yes/No instance parameter to family

Hi everyone,

Which invalid parameter type is the node referring to?

I think your type is fine, maybe try finding another way to retrieve the document without opening it.

@L.Cunningham thanks for the answer. What would you suggest? Can this node even be used without having the family open (or at least in background)?

I apologize, I was incorrect adding parameters to specific families as opposed to global or shared parameters does require a change to the rfa meaning you would have to open the document.

That being said, sometimes I have some weird issues with dynamo hanging on to things from previous runs, so if you haven’t already you could try close out dynamo and possibly the revit file you’re running it on and do a completely fresh run to get rid of anything that it may have cached.

no luck. I just checked that the parameter name has a different input string[] instead of string?

The only other thing I can think to try would be to change your group to something in the enumeration. So replace “Visibility” with “PG_VISIBILITY”

Unfortunately doesn’t work.
I found this thread https://forum.dynamobim.com/t/create-type-parameters-in-dynamo/3200/4 and I was able to re-type the code so it works if I want to add ONE Type parameter. But if I need to add a list of Instance parameters (defined by string) it doesn’t work. I need to change the code but I am not familiar with Python

If you somehow could help me with that… :slight_smile:

import clr

clr.AddReference(“RevitServices”)
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference(“RevitAPI”)
from Autodesk.Revit.DB import *

par_name = IN[0]
par_type = ParameterType.YesNo
par_grp = BuiltInParameterGroup.PG_VISIBILITY
TransactionManager.Instance.EnsureInTransaction(doc)

OUT = doc.FamilyManager.AddParameter(par_name, par_grp, par_type, False)

TransactionManager.Instance.TransactionTaskDone()

You need to use a for loop to iterate through each of your values in “IN[0]”

import clr

clr.AddReference(“RevitServices”)
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference(“RevitAPI”)
from Autodesk.Revit.DB import *

par_name = IN[0]
par_type = ParameterType.YesNo
par_grp = BuiltInParameterGroup.PG_VISIBILITY
newParams = []

TransactionManager.Instance.EnsureInTransaction(doc)

for name in par_name:
    newParams.append(doc.FamilyManager.AddParameter(name, par_grp, par_type, False))

TransactionManager.Instance.TransactionTaskDone()
OUT = newParams

Side note, use this little button to get your code to show as scrollable text :+1:

2 Likes

Orchid has some great nodes for opening family documents in background, and adding parameters to them.

@L.Cunningham thank you very much. It worked like a charm. I just had the
newParams.append(doc.FamilyManager.AddParameter(name, par_grp, par_type, False)) set to true since I want my parameters to be instance

Thanks for the tip about the code posting :slight_smile:

1 Like

@GavC I started with them (see first post) but somehow there was a problem with my inputs that I still don’t understand. That why I changed to a solution based on python.

1 Like