Revit Dynamo Combining Spring node family instance by geometry with Associate Family parameter

Hi everyone, i am quite new with Dynamo and I am having some issues trying two combine two nodes in order to be able to export a geometry as a family using the Spring node family instrance by geometry, by instead of adding a material to the created element I would rather link this element to an associate family parameter created previously in the template I am using with the Sping node. I have tried using the python script developed by @awilliams and @3Pinter but was enable to put the two scripts together. (Associate family parameter in a family)

I hope what I am trying to do makes sense. Any help would be appreciate :wink:

Here is the Python script they have been developing last year :

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

clr.AddReference('RevitNodes')

import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument


elements = IN[0]
epSearch = IN[1]
fpSearch = IN[2]

if not isinstance(elements, list):
	elements = [elements]
if not isinstance(epSearch, list):
	epSearch = [epSearch]
if not isinstance(fpSearch, list):
	fpSearch = [fpSearch]

for e in elements:
	e = UnwrapElement(e)
	elemParams = e.Parameters

	epNames = []
	fpNames = []
	elemAssoc = []
	famAssoc = []
	
	for ep in elemParams:
		epNames.append(ep.Definition.Name)
		
	epDict = dict(zip(epNames,elemParams))
	elemAssoc = [epDict.get(ep, "none") for ep in epSearch]
	
	famParams = doc.FamilyManager.Parameters
	
	for fp in famParams:
		fpNames.append(fp.Definition.Name)
		
	fpDict = dict(zip(fpNames,famParams))
	famAssoc = [fpDict.get(fp,"none") for fp in fpSearch]
	

	TransactionManager.Instance.EnsureInTransaction(doc)
	
	for i,j in zip(elemAssoc,famAssoc):
		try:
			doc.FamilyManager.AssociateElementParameterToFamilyParameter(i, j)
			error_report = "No errors"
			
		except:
			error_report = "can't assign parameter"
	TransactionManager.Instance.TransactionTaskDone()


OUT = elements,error_report

The thing is that the Sping node allows me to create a family from a project but I don’t want to have to import manually material to the family template since our family library might change so I would rather be able to change the material afterwards. I was using the Spring node because i was giving me the possibility to create voids, but there might be a better option.
The script of @awilliams and @3Pinter is working fine in a family document but I have to select manually the freeform since there is no node to select all freeforms in a family document, or at least, I havent found a way.

It was quite a battle to download you package but works perfectly ! Thanks a lot

Yes but all the packages are on a local server and the executable moved everything on the computer itself :wink:

Hi @erfajo, I though I managed to use is correctly but it seems that I still have some issues with it and don’t really understand how to connect the two parts of what I am trying to do. Attached is an example of what I am trying to do with a simplier geometry.

Test.dyn (36.6 KB)

Hahaha, yes indeed that’s the one you sent me, I tried with replacing the directory path with the directory path of my file and the parameters with mine, which have previously been created in my family template, this was just an example, sorry …

Sorry if I wasn’t clear, I am creating a family, inside a project, my goal is automate the action of applying to everything that has been created inside this family an associate parameter.
May be, what I am not understanding very well is how the directory.contents node works. And maybe I am completely wrong with my approach.

I might not understand how the associate parameter nodes works but it does not seem to want to take an Autodesk.Revit.DB.Document as a parameter, while the addsharedparameter node will.

(The blue nodes were there in order to replace the grey ones right ?)

PS : I really appreciate your help

My Bad, it works now ! Thank you so much for your help

Capture4

For anyone who might be interested in the process, here is the dyn file :slight_smile:
Thanks a lot @erfajo, your help is really appreciated

Capture5 Test.dyn (38.2 KB)

@erfajo Ok, I a still adding too many nodes, I don’t always use them in the most efficient way …

The one just before the associate.parameter node :wink:
I will create a custom node for this process, I think I am going to use it a lot :wink:

1 Like

FamilyInstanceWithAssociateParameter.ByGeometry.dyn (33.5 KB)

My bad

2 Likes