Associating Global Parameters to a family in a project


#1

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!


#2

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)


#3

@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).
https://drive.google.com/open?id=1giv4F5LC2ZIpC2xkhCWVCgn38MXq8-Ze

P.S. @awilliams is awesome!


#4

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?


#5

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.


#6

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:


#7

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


#8

@lucamanzoni

The user @rdeardorff did ask me for this node at my GitHub. However, I was busy finishing my minor update first. That was uploaded late last night (Orchid package --> released at Github) …so this forenoon I made the node and as you demonstrate it is very easy to make. It took longer time to make the icon for the node :wink:

Parameter Associate.dyn (6.2 KB)


As it can be seen, it takes both string and global parameters as input values…


#9

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.