Associating Global Parameters to a family in a project

All,

Do any of you know if there is a way (through nodes or python script) to associate a families parameters to a projects Global Parameters using Dynamo?

I have been using Orchid’s Parameter.Associate to associate nested family parameters to the host families parameters with great success but this obviously does not work in a project setting.

The end goal is to be able to select a titleblock and then have the graph associate the global parameters to the proper titleblock parameters.

Any ideas or thoughts would be super helpful!

Thanks!

1 Like

Yes, it’s possible with AssociateWithGlobalParameter Method.

It’s just a bit tricky to get the correct parameters, but I got some help from an old post from @awilliams (Thank you!)

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

element = UnwrapElement(IN[0])
name = IN[1]
gp = IN[2]

#Get parameters from element
parameters = element.Parameters
myparam = []

TransactionManager.Instance.EnsureInTransaction(doc)

#Get parameters with the input name
for param in parameters:
    if param.Definition.Name == name:
        myparam.append(param)

#Associate parameter
for x in myparam:
    try:
        x.AssociateWithGlobalParameter(ElementId(gp.Id))
        out = "Success"
    except:
        out = "Fail"

TransactionManager.Instance.TransactionTaskDone()

OUT = out

This is just an fast example that works with one element at a time, maybe @erfajo can do a custom node for his Orchid package (and thank you very much for what have you done so far)

4 Likes

@lucamanzoni

My first try with this failed. Here is what I am seeing:

The warning text reads:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 51, in
NameError: name ‘out’ is not defined

Here is a sample project I am using along with the graph included. The titleblock on the right is the one that is needing to be associated (the one on the left is already done).

P.S. @awilliams is awesome!

BTW I am thinking this might have something to do with your setup looking at a model element and mine looking at a titleblock instead of an actual modeled element. If I use the Select Model Elements node I am not allowed to select the titleblock at all. Using Data-Shapes I am allowed to but it doesn’t work.

Does the script need to be updated to accept annotation families?

I also wonder if maybe it is not seeing the parameters because they are type parameters and not instance parameters. If I run the titleblock family through the Element.Parameters node I don’t see any of the type parameters.

I forgot to mention that not all the Parameters can be associated with a Global Parameter. You can easily check in Revit if you have a small button close to the parameter (that’s how you would manually associate in Revit, without Dynamo).

The graph I posted was to associate instance parameters, if you want to change type parameters you need to use Family Types:

This works. I modified the selection process slightly so that the user can simply run Dynamo Player and select the titleblock without having to open up Dynamo. Here is the final result:

Thanks again @lucamanzoni

And this is one of the reasons Dynamo is so awesome. It’s not just the program itself…it is the community! You guys have made my week. When I finish cleaning up my graph(s) I will post a few samples of what I have been able to accomplish for my company and hopefully it may be useful for others.

2 Likes

Great, guys! I was looking time ago for associating Global parameters for title blocks parameters. Here’s the solution. Parameter.Associate was the node I needed. Thanks for Orchid package!!!

Bravo! I found this method to be super helpful!

This might be for another topic, and I’ll move it if it is, but is there a method to associate a global parameter to a list of (or multiple) family types?

Here is the link to the new post.