Associate Element Parameter to Family Parameter Python

Hello everyone,

I am trying to associate within a Family Document some family parameters to the element parameter called “Cuts Geometry” using the Revit API FamilyManager.AssociateElementParameterToFamilyParameter method:
image
I got several voids in my family document and I´d like to associate some family parameters that I have created to the “Cuts Geometry” element parameter:

To do so, I tried to follow the post solved by @awilliams . After many tries, I ended up posting here the issue that I am struggling with in order to get any piece of advice.

You´ll see that the Python node says “no errors”. However, if I double-check the family document, I can see that the same family parameter has been assigned for all the elements:

image

Thank you!

Make sure you’re unwrapping your Revit objects when using the API.

I did that on the line 30 of the code. Should be done differently? @Nick_Boyts

Nope. I just missed it.

Are you in the FamilyManager when you run this? You’ll have to open a new family document for each element in order to get the proper FamilyManager which it looks like you’re not doing.

I run the script within the Family Document and pointing at that Family Document, if that is what you mean with FamilyManager.

Yes. If you’re doing that for multiple elements/families you’ll have to automate that as well. Or are these embedded elements within the same family?

Your error report is also just reporting for the last element since you’re not maintaining a list for each element.

Those elements that you can see in the previous screenshot that I attached are different voids within the Family Document so we can assume all the elements (voids) are embedded within the same family, right?

With your second phrase, you mean that instead of having all the inputs flattened in a list, should I have the inputs split into sublists of length = 1? inserting a List.Chop

If the elements are in the family then you’re good.

Right now you get the error_report for each element but you only return it with the final output. Which means you’re overwriting the value each iteration and then only returning the value for the final element. You’ll need to create a list for storing each value or have a check to retain any failures instead of overwriting each time.

Well, I think what you are behind @Nick_Boyts . It is true it is a little bit tough to debug the code as I have set as output = elements (same as the input) and the error_report. The error report is just showing the last iteration (for the Pier_6 I guess) and we cannot identify if the code has been run for the rest of the elements properly due to the fact that I am not appending the error_report for each iteration to any list.

I will update the code with that approach but thats only for debugging the code. I will still remain with the issue that I will have the Pier_6 family parameter associated with all the Cuts Geometry element parameters…

Correct. That’s just to see if any of the other values are working. As Pier_6 is the only one working and the only error value we get, we can’t tell what is happening with the rest of the values. I would also recommend outputting other checks along the way, like the parameter dictionaries and returned values.

Hi again @Nick_Boyts ,

I tried what we were discussing… with no success…

You will see that I have simplified slightly the code and I also debugged with the OUT. Everything seems to be ok but now none of the elements have any family parameter associated…

Ah. You’re storing the parameter names and then trying to link those instead of the actual parameter. You need to use the name for parameter matching but the actual parameter element when linking them.