Set Parameters of Multiple Family Documents and Types

Split from original topic:

@erfajo

How can I do it in multiple familys / types with different values?

The problem is your lists don’t match and not everything can be handled by list levels. Your best bet is to duplicate values so you have one-to-one inputs on everything.

Ah good tip! Will try tomorrow

@Nick_Boyts do you mean like this?


It still doesn’t work

I think you just need to flatten the document list. If the inputs have the same dimensions they’ll be treated evenly. Right now that would mean one document per input. A flattened list would put you at one document per sublist of inputs.

@Nick_Boyts Thanks for the reply.

Unfortunately, I doesn’t work:

So this means it’s not possible with multiple familys/?

What does your output look like? Have you messed around with list levels? They may not even be necessary now.

@Nick_Boyts All values in the types are the same.

I noticed you also have lacing set on the node. I’d change this back to auto if you haven’t tried that already. Worst case scenario you should be able to duplicate the document list as well. It’ll probably be a lot slower but it should force everything to align correctly.

1 Like

With auto the same result. So the document and the types the same, and the parameters/values?

Orcon.xlsx (10.1 KB)
Test.dyn (69.2 KB)

Over here some files if someone want to test.

Can you share families as well? Or setup an example set that can be shared?

@Nick_Boyts
Sure, in the appendix 3 rfa files.
In this case I use the excel file for the rfa files and the parameter, not for the values yet.
57_ME_UN_HRC-300-500 rechts_Orcon.rfa (1.7 MB)
57_ME_UN_HRC-300-500 links_Orcon.rfa (1.8 MB)
57_ME_UN_HRC-425-570 links_Orcon.rfa (2.6 MB)

My endgoal is set all the parameters in all the types with all the values from my excel.

I had no luck either. Might be time to get @erfajo involved.

1 Like

@Nick_Boyts

i tried it with python yesterday. there I had retrieved the types from the familys and if the parameter matched the input, then take the parameter per type. but the point is that they are family parameters and not familytype parameters.

What do you mean by this? A Family Parameter refers to where the parameter is being applied from (family vs project or family vs shared). A Type parameter refers to how the parameter is applied to the element (family type vs family instance). I don’t think any of this should matter when you’re interacting with the family in the family environment. The family document will have both the type and the instance parameters so you should just need to find the match.

@Nick_Boyts This is what I have, but somehow it doesnt work:

I retrieved the parameters for each type but somehow it doesn’t do the trick.

import clr #.NET Laden
import sys #sys is de fundamentele Python bibliotheek
#de standaard IronPython-bibliotheken
sys.path.append(r'H:\BIM-REVIT\00 GEBRUIKERSGROEP BIM\00 BRONBESTANDEN\Python\defs') #Imports the
#standaard IronPython-bibliotheken, die alles dekken, van servers en
#encryptie tot reguliere expressies.
import functies as fc
import System #The System namespace in de hoofdmap .NET
from System import Array #.NET class voor het verwerken van array-informatie
import System.Collections.Generic as MGen #Module kan nu benaderd worden met MGen.xxxx
#from System.Collections.Generic import * #Hiermee kunt u generieke afhandelen. Revit's API
#soms wil hard-getypte 'generieke' lijsten, genaamd ILists. Als je niet nodig hebt
#deze kunt u deze regel verwijderen.
clr.AddReference('ProtoGeometry')  #Een Dynamo-bibliotheek voor zijn proxygeometrie
#classes. Je hebt dit alleen nodig als je interactie hebt met geometrie.
import Autodesk.DesignScript.Geometry as AGeo #Module kan worden opgeroepen a=met AGeo.xxxx
#from Autodesk.DesignScript.Geometry import * #Laadt alles in Dynamo's
#geometriebibliotheek
clr.AddReference("RevitNodes") #Dynamo's nodes voor Revit
import Revit #Laad in de Revit-namespaces in RevitNodes
clr.ImportExtensions(Revit.Elements) #Meer laden van Dynamo's Revit-bibliotheken
clr.ImportExtensions(Revit.GeometryConversion) #Meer laden van Dynamo's
#Revit-bibliotheken. Je hebt dit alleen nodig als je interactie hebt met geometrie.
clr.AddReference("RevitServices") #Dynamo's classes voor het omgaan met Revit-documenten
import RevitServices 
from RevitServices.Persistence import DocumentManager #Een interne Dynamo class
#dat het document bijhoudt waaraan Dynamo momenteel is gekoppeld
from RevitServices.Transactions import TransactionManager #Een Dynamo class voor
#transacties openen en sluiten om de database van het Revit-document te wijzigen

clr.AddReference("RevitAPI") #Verwijzing naar Revit's API DLL's toevoegen
clr.AddReference("RevitAPIUI") #Verwijzing naar Revit's APIUI DLL's toevoegen

import Autodesk #Loads the Autodesk namespace
import Autodesk.Revit.DB as RDB #Loading Revit's API UI classes module kan nu worden aangeroepen met RDB.xxxx
#from Autodesk.Revit.DB import * #Loading Revit's API UI classes
import Autodesk.Revit.UI as RUI # Loading Revit's API UI classes als RUI.xxxx
#from Autodesk.Revit.UI import * #Loading Revit's API UI classes

#doc = DocumentManager.Instance.CurrentDBDocument #Dit is het actieve Revit document
uiapp = DocumentManager.Instance.CurrentUIApplication #Een handle instellen voor het actieve Revit UI-document
app = uiapp.Application  #Een handle instellen op de momenteel geopende instantie van de Revit-toepassing
uidoc = uiapp.ActiveUIDocument #Een handle instellen op de momenteel geopende instantie van de Revit UI-toepassing
   
def uwlist(input):
    result = input if isinstance(input, list) else [input]
    return UnwrapElement(result)

# einde code omrekenen revit feet naar huidig ingestelde document units
# Hieronder kan je dan gaan programmeren
# Gebruik boiler template

#Start Transaction
#TransactionManager.Instance.EnsureInTransaction(doc)
#Eind Transactie
#TransactionManager.Instance.TransactionTaskDone()

docs = uwlist(IN[0])
str_para = IN[1]

parameters = []

TransactionManager.Instance.ForceCloseTransaction()

for d in docs:
	fam_mgr = d.FamilyManager
	params = fam_mgr.Parameters
	for p in params:
		if p.Definition.Name == str_para:
			fam_types = fam_mgr.Types
			for t in fam_types:
				parameters.append(p)


OUT = parameters

After that I used the Set method and save the doc but revit crashed after that and the family is saved 3 times.


TransactionManager.Instance.ForceCloseTransaction()

for d in docs:

	#Transactie openen
	TransactionManager.Instance.EnsureInTransaction(d)
	#subtransactie maken
	trans = Autodesk.Revit.DB.SubTransaction(d)
	
	#subtransactie starten
	trans.Start()
	
	fam_mgr = d.FamilyManager
	params = fam_mgr.Parameters
	for p, v in zip(params, values):
		if p.Definition.Name == str_para:
			fam_types = fam_mgr.Types
			for t in fam_types:
				fam_mgr.Set(p,v)
				
	trans.Commit()
	
	TransactionManager.Instance.ForceCloseTransaction()
	
	d.Save()
	d.Close()

OUT = parameters

image

I don’t know if this will fix everything but your lists don’t match in structure which I think is still going to be a problem. We can’t actually see all the inputs as you’ve supplied them so I’m only guessing based on your code structure.

You don’t show where values comes from but I’m assuming it’s a list of values that you supply as an input. I would have assumed the same for params since you first went through each type and identified them but you then define params as all parameters in the family manager again. This also makes it seem like params and values no longer match. Similarly, you haven’t shown where fam_types comes from but assuming it’s the type list you also had created the structure doesn’t match and you’re now trying to assign parameters to every type within each document, not just the family the types came from.

In my mind, it would be easier to set the parameter in the first python block instead of redoing some of the work a second time. It may also help with maintaining the proper list structures.

Side note: I just now realized this wasn’t originally your thread and we’ve pretty well hijacked it. I’m going to see about getting it split into a new thread.

It doesn’t work, so I had everthing in structure.
So as I understand you well, I need to create list for each doc with his own parameters?

Hehe, yes good choice :slight_smile:

I still haven’t seen the inputs for the two python blocks so I can’t say for sure, but the looping structure doesn’t seem to match your intent. So yes, a list of docs, a list of parameters by doc, and a list of values matching their parameters.