GetAssociatedFamilyParameter, with two arguments?

Dear Dynamo users,
I’ve got a question for you.
I’m trying to create this custom node in Python with the method GetAssociatedFamilyParameter(),
from the FamilyManager class.
When I’m running this in Dynamo it’s telling me that the method requires two arguments (one is given)
The RevitAPIdocs says (from the C# syntax):

public FamilyParameter GetAssociatedFamilyParameter(
	Parameter elementParameter
)

My question for you is: where’s/what’s the second argument?

Thanks alot!

Where are you seeing the error? Can you post the exact text and the python?

@JacobSmall, this is what I’ve written so far:

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
clr.AddReference(“RevitAPI”)
import Autodesk
from Autodesk.Revit.DB import *

dataEnteringNode = IN
elems = UnwrapElement(IN[0])
outlist =

for i in elems:
try:
outlist.append(FamilyManager.GetAssociatedFamilyParameter(i.GetParameters(‘Visible’)))
except Exception as e:
outlist.append(e)

OUT = outlist

This is without running the code with the exception part:
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 13, in
TypeError: GetAssociatedFamilyParameter() takes exactly 2 arguments (1 given)

I have been getting similar issue’s between the number of arguments required with the Revit Api saying 2 Arguments for C# and then and error message and asking for 3 arguments in python in Dynamo for SetSketchPlaneAndCurve(), but not telling me anywhere why or what the miss argument is.

I am also yet to find away in Python in Dynamo or Visual Studio that when you open the bracket it gives you an idea what is required in the same way as Design Script does in dynamo code blocks.

grafik

1 Like

Are you in the family environment, and only processing the active document?

Yes, I’m in the family environment.
The input is a list of Filled Regions, and for every i in the list i want to take a closer look at the “Visible” parameter and check which family parameter it’s associated with.
And yes, the Filled Regions are placed in the active document.

Try making it work for a single filled region and remove the for loop. Might shed some light. I have seen this happen because there is a similar API call which Revit is trying to use, but I cannot think of which it would be offhand.

I tried to send in only one element and removed the loop.
Did not work.
I’ve experienced this with several other methods as well, just as @Matt_Gaydon.
Any thoughts?

Try feeing it a static second variable to see what it expects as the input?

Are you missing a reference to the document? FamDoc.FamilyManager()?

Yeah, so I tried to do that before and it tells me it expected FamilyManager. I know for some methods you need to construct a new, in this case a FamilyManager, for it to work. Like with a filter, the Create method. But I couldn’t find anything like that.
So, the GetAssociatedFamilyParameter expects (FamilyManager, elementParameter)(?)
Keen eye there @SeanP but something is telling me that isn’t the issue though.
Since Dynamo is finding the method and I’m in the family document (and now got a reference to it), Dynamo is basically telling me that “Hey, I know this method but you still need one more argument for this to work”.
Please, correct me if I’m wrong here but shouldn’t it be explicitly mentioned in the RevitAPIDocs even though it was a reference or not.
In some methods it says “doc Current Document” as an argument.

I think your getting your parameters wrong. If your trying to look them up by string, you will need

I.LookupParameter(“paramName”) or I.GetParameter(BuiltInParameter.VIEW_SCALE) for BIP.

Take a look and make sure your constructing that correctly.

It was exactly as you told me @SeanP, I added the family manager as an argument in the GetAssociatedFamilyParameter. As for the LookupParameter() vs GetParameters() they both work. The difference is that GetParameters() returns a list of parameters, which I guess is helpful some times.

This is the piece of code is used to get it working:

FamilyManager.GetAssociatedFamilyParameter(doc.FamilyManager, elems.LookupParameter(“Visible”)).Definition.Name
alt.
FamilyManager.GetAssociatedFamilyParameter(doc.FamilyManager, elems.GetParameters(“Visible”)[0]).Definition.Name

Since the GetParameters() returns a list i defined which index to get, since I knew that it only contained one parameter.

Thanks a lot!

3 Likes