Batch add units format to text parameter in family

Hi All,

New here and, like many, I am a beginner and a bit over my head. What I am attempting to do is to use Dynamo to take family files in a directory, inspect those files to see what the units are, then add the units as a text parameter within the family. For example, check a family to see if it is “METRIC” or “IMPERIAL”, then create a new parameter in that family and add the information into the parameter.

I have a bit of python code that I modified to find the units. Where I am actually struggling is using some Orchid nodes to load the parameter data. I’m getting error messages for the “familyDocument” input. I’m not sure what I need to attach to that node if I am trying to pull multiple files from a directory. Also, I’m not sure how to save the files at the end of this graph because after perusing other forum posts it looks like the Orchid outputs used to be “Document” but now are “Parameter”. I don’t know how to save and close the documents that are open in the background.

Any help is much appreciated!

Hi and Welcome!

It seems Rythm and Orchid don’t play nice together. I looked at the Description of the FamilyType.All Node from Orchid and it states: “Family Document (rfa) as Orchid Document”, which means you need to provide a “Orchid” Document and not an Revit API Document (Which Rhythm does…)

To get an Orchid Document, you need to Load the Families you want to modify into your project and from there use Family.EditFamily from Orchid. This returns the Open Family Document as an Orchid Document.

It would be nice it the guys from Orchid made a Node which can take a Revit API Document (Autodesk.Revit.DB.Document) and parses it to an Orchid Document

1 Like

Hey All,

If you find any issues, you can always post at the Orchid Github. https://github.com/erfajo?tab=repositories

I think, mostly, you’ll find Orchid nodes to do the whole process, so I’d usually dig around in there.

In this instance, I think this graph is quite similar to what you’re after?


https://github.com/erfajo/OrchidForDynamo/blob/master/Samples/Dynamo_2.x.x/Families/BulkUpgrade.png

Dyn Samples

Hopefully that’s useful,

Mark

1 Like

Seems like I just found a whole new section of Orchid :sweat_smile: Should use it more often

1 Like

Glad to be of service :slight_smile:

I find there are certain tasks that I can’t do any other way… Parameters in families are one of them…

Cheers,

Mark

I will take a shot at updating my graph using yours as an example. I appreciate the help.

1 Like

It’s not mine, it’s Erik’s so hopefully it will work :smiley:

Best of luck!

I need Python help to get this graph to working. I have some code (in attached text file) to search through the files open in the background, to find the units, and then set that value to an existing text parameter. The parameters is a type parameter if that matter. I seem to making a mistake in setting the parameter and I’m sure there are other mistakes in the code as well so any help that anyone can offer will be appreciated!

File_Family_AddUnitsToExistParameter_Python.txt (1010 Bytes)

File_Family_FindUnits_AddtoParameter.dyn (17.2 KB)

Hey,

Erik answers all queries through his Github… I’ll try and have a look tomorrow.

Apologies,

Mark

Hey,

This seems to work for me, what you’re doing is slightly unusual, I’d ask Erik to make you a node.

I’ve had to hack it a bit, I always find background opening a bit worrying…

Hopefully that’s useful,

Mark

File_Family_FindUnits_AddtoParameter-MA.dyn (56.0 KB)

Thanks @Mark.Ackerley , I hadn’t thought that you could combine the background open nodes in the same graph. I noticed that this seems to work for the first family in a folder, but fails after that (at least in the case where the parameter didn’t exist previously). Did you try that out? I will take another crack at it using this as inspiration.

Also, for my own edification, why do you pass the documents output into an “x” parameter in the code block in various locations within the graph?

Hmm…

Yeah unfortunately I’ve run out of time, so have a go and report back :slight_smile: i think it is all fine because the close node gets to run.

I use the x codeblocks just to keep it tidy, I believe Archi-Lab might now contain a Relay node which would be cool!

Cheers,

Mark

@Mark.Ackerley I got it to work. I will clean up my graph and post it later tonight or tomorrow. Thank you so much for your help.

Attached is the updated graph. Unfortunately, I’m still running into some head-scratchers. First, I found it works better to run a graph that adds the parameter first (no errors with that). I’m just getting an error with setting the parameter.

If I run this on a folder full of families that each only have one type, then it runs perfectly. If I run it on a folder that contains one family and that family has multiple types, then the Set Parameter node will kick back an error, but the parameters do get set in the types and it saves. If I run it on a folder where there are multiple families and at least one of them has multiple types, then it will set the parameters for each family that only has one type until it runs into the first family that has multiple types and it will stop (also giving an error at the Set Parameter node).

I will keep at it, but again any help that can be offered is much appreciated.

File_Family_FindUnits_AddtoParameter_CSUpdate.dyn (74.2 KB)

Hey,

Glad you got it working, if only in part.

Good work on posting to Github :slight_smile:

It sounds like inconsistencies with how the nodes are handling lacing and levels, it might be that you can help the nodes out by chopping your list of families and running everything at L2? Obviously that impacts your Python.

Cheers,

Mark

Here is the solution. I am using two graphs, although you could use just one. I’m adding the parameter with the first graph and then setting the parameter with the second. Both require Orchid and the second requires Rhythm as well. Thanks so much for your insight @Mark.Ackerley!

File_Family_AddSharedParameter.dyn (30.9 KB)

File_Family_FindUnits-AddtoParameter.dyn (46.0 KB)

1 Like