Rename a shared parameter in family to match the family type name

I use R2024 and my families have a shared text parameter called “SHARED TYPE MARK”, which I use for the typemark of elements and show in a tag and schedule.

I try to also name the family type the same the exact same way. Now my idea is to name the family type and then run a Dynamo script to read that name, and apply that to the “SHARED TYPE MARK” parameter.

I envision to select one instance of the family with dynamo, then run the script and all those shared parameters get named to match the type name.

I’m a noob, I started something, but I’m stuck. I managed to select one element (obviously this is only one of the types) and somehow read the family name, but it actually focusses more on reading the type name.

Could someone point me in a better direction?

Typemark_Naming.dyn (15.3 KB)

EL_Emergency-Lighting-Inverter_Myers_Illuminator EM.rfa (464 KB)

ElementType.FamilyName should return the family name rather than the type name.

1 Like

And a better approach would be to run your script over not just the selected element, but over all the loaded elements of whatever catagory you want. This appears to be electrical equipment. By running the script over all the loaded equipment types, you won’t have to constantly update your loaded families one by one. (The idea is to save time, right?) You can run the script before printing and know all the values are up-to-date.

You don’t need a special shared parameter for “Shared Type Mark” You could have just used the built-in Type Mark field. It schedules an tags. You just don’t see it until the family is in the project (So you can’t pre-set it.) but no matter! you have a script to set it in the project to the correct value. Woo hoo! Adding a lot of unneeded redundant parameters if the Achilles Heel of Revit.

Also - start looking at the Revit api. You’ll need it sooner or later. For instance. getting the items you want to work with will take several nodes. Where in python it is one call (and fast)

elems = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_ElectricalEquipment).WhereElementIsElementType().ToElements()

And to jump way ahead in your learning…
If this were done in the aip with a dynamic update (IUpdater), you would never have to actually run a script. Revit would do it for you every time a new piece of electrical equipment is addded to the document or some renegade draftsman tries to change the parameter to the wrong value - it would change it back to the right value. But I digress.

1 Like

Thank yo both.

I tried to ElementType.FamilyName, but it just gave a me null value. I’m also not sure I actually need the family name. I think what I need to do is:

  • select the family (it seems I only can select an element, so I only select and instance, or a type). There wasn’t a way to select a family in the project browser.
  • read all the Type names (my attempt with Element.GetPArameterValueByName only gives me that specific type name, not all)
  • apply all those type names to the shared parameter. I tried the Element.SetParameterbyName

I’m still stuck (obvioulsy)

I don’t want to automate it to do all families, or all families in a category. I edit one family at a time, consciously name the types and then want to push a button to rename that shared parameter for that family only. Not all my families may follow this scheme, and some don’t even have that shared parameter. For now at least, it would be family by family. Much of the work is in the original editing (coming up with type names etc.)

My current workflow is to rename the type, then copy&paste that to the shared parameter. So if the family has 10 types, I have to copy/paste 10 times.

You can select an item(s) in the browser. Just highlight it in the browser and it is the current selection. (Assuming you haven’t selected anything else in the drawing area.) But Dyanmo doesn’t have a default node for this. Maybe there is a custom node for this. But it is easy with Python.

Current Selection:
Getting the current selection in Revit? - Dynamo (dynamobim.com)

This should give you everything you need from a selected object(s) on the screen.

If you are making families with this information pre-set - then a Type Catalog is your first and best option for enforcing this naming system It is per family and simple to set up - no programing. (You have a type catalog? Yes?) Just basic Revit.

You can easily filter out just those families you want to automate. No shared parameter - kick them off the list of all elements of category. You could filter by name with a dictionary of names. Plenty of other ways to filter as needed. So don’t rule out a more broad based approach to automation. If you are going to do it one at a time - might as well stick to copy/paste.

1 Like

For some reason I can’t select in the browser. Yu mean just click on the family name or the type?

Typemark_Naming.dyn (20.0 KB)

I copied what you showed and it worked so far. I then used Element.GetParameterValueByName to get a list of variables with the type names. i then tried to use Element.SetPArameterByName to set that shared parameter.

but I’m not sure how to select the element. the Warning indicates it requires one of the Revit.Elements. I looked through those nodes, but didn’t see anything that looked right. I then also need to find what to connect the output to.

I also found the FamilyDocument.SetParameterValueByName tha tuses the family document. but that may be a dead end.

On the type catalogues, No I don’t use them. I tried to use them to add new types in Excel or Google sheets. and that indeed could help here since I could just make that shared parameter match the type name. But here is why I found it doesn’t work well:

  • Light fixture families contain “ies” files for each type from the manufacturer that my plugin uses for lighting calcs in Revit.
  • I usually create or edit families in a project. So I need to edit the type name in the project. If I would just edit that in the Excel file, and then reload the family, the old types (before renaming) also would be in the project. This idea of making the type name be the same as the type mark is a recent idea of mine. So I’m experimenting and may change my scheme and try new type names.
  • I would have to switch to Excel, then export to txt file and so on. I also need to do QC (so it shows the correct values schedules or tags etc.). So not doing it live in Revit, but having to use multiple other software to me is cumbersome.

I’m not excluding automating more. but want to get this to work for one family first. And in projects it is usually one family t a time I create or edit. Easier to do QC on one family at a time. Like if a project requires an additional model of a light fixture, I then add this type or create a new family, but the magic only should be applied to this family.

The Select node can only select from the project window - not the browser. So, you would need to have an instance in the project to use the Select node. This could work just fine.

To use items not placed in the project, you would have to first select the object in the browser and then run dynamo. The link I posted shows how dynamo will pick up the already selected object(s).

The attached lets you select a Family type in the browser and returns all types within the family. It uses some python to keep things simple. (If it were all python it is even simpler - but this is dynamo.)

Yes - You are in a project - not the family editor, so the FamilyDocument.SetParameterValueByName isn’t going to work.

Select In Browser.dyn (7.0 KB)

1 Like

You can put IES files in a type catalog.:
Embedding IES in Type Catalogs for Revit Lighting Fixtures (kinship.io)

Since you are indeed doing type catalogs with Excel - that too can be automated. Updating the type catalog on the fly would help build your library, instead of doing it on each project. In fact, the whole process of adding a new type to a family catalog, loading it and placing it can be automated.

Duplicate type > Input new data > Send data to Excel > Send data from Excel to the type catalong > Load family type in new project. You wouldn’t even need to open Excel or the type catalog.

1 Like

Thanks. I’m actually fine selecting an instance in the project since when editing families, I usually have one placed in the project. and yes, I don’t think i need that in the family editor, so won’t need the familydocument nodes. I wasn’t aware they aren’t for the project.

It looks like I have the beginning of the script to read the type names. Is the Element.SetParameterbyName the correct next step? If so, where do I get the element (yellow highlight is wrong, I know) from?

Thanks for sharing that ies-in-type catalog link. IIRC, I tried something similar a long time ago. But the weird characters looked sketchy and I wasn’t able to create new types in Excel. It looks like the new type (with the ies file) still has to be created in Revit. So this doesn’t seem to help me creating new types.

My families actually only have the types I actually use. A fixture may have 100 models, but only 8 will ever be used. So I only create the 8 I actually need. And I like all of them loaded so I see in the project which ones are available (i.e. different lumen packages, or distribution options). And during the design I change the types used. So not loading all available fixtures isn’t really good for my workflow. And besides the ies file, more types don’t really add much more memory requirement since the added information are just the values for each type.

Maybe I misunderstand the purpose of the type catalog, but all examples I see are around families with many dozen, or even hundreds of types. I tried to use the type catalog more to create new types.

Making it way too hard. Attached.
Select In Browser and Name.dyn (12.0 KB)

Now this does all loaded types. Not just the selected. If you ONLY want to do the one - then you don’t need to get all the type. Just the one and you already have it.

1 Like

You don’t HAVE to fill out the IES data in your Catalog. The advantage is that it will always have the right Photometric web no matter what.
You can just input the web file name in the catalog type and it will load the IES file from the source when you load the family. Just leave the special caracters out. Simple enough. Of course, the correct IES files need to be available on the server.

image
image
image

This works! Thanks so much. This turned out really well.

I adapted your code to sue the "Select model element) to select. So one script lets me select an actually placed family. And yours from the one in the browser.

I was hoping just having both codes in one script lets me use it either way. but they seem to need to be separate files.

I tried it out in the project by just renaming the types. It seems using your method to use the browser works better in real life and with the dynamo player:

  • I edit a family (and their type names) in the browser. So renaming those parameters at the same time makes sense and doesn’t require me to find that family in the model
  • I could edit a family before I actually place an instance.
  • It also seems to work a bit more reliable in the dynamo player. When I manually select an instance in the model, it seems I have to have it selected before running the script. Otherwise it will use the last family I had selected. so the browser method seems to be a bite more controllable.

On the ies file, where would the files have to be located? Would they just be in the same same folder as the txt file? I have my families on a network folder, not a server (well, that folder is on a server, but it acts like any folder). That folder has a sub-folder with the ies files (I usually clean them up to just have the ies files I actually want since some manufacturers provide them for each version). I’ll have to look more into this. Sometimes it may be easier to see all parameters in a table to do a sanity check.

Last time I tried to play with txt files for types (and keynotes) I used Excel. Since then I switched to google sheets since that works so much easier. I may try that for type catalogues.

The nice thing about inserting the ies file in the family editor is, you see the shape of the light distribution right away. Sometimes manufacturers use the wrong (or same file for actually different distributions) and then you have to go back to them to have it corrected. So the visual feedback to an ies file is nice. Or if you select the wrong one

Type Parameter Naming - Browser.dyn (12.2 KB)
Type Parameter Naming - Model.dyn (13.2 KB)

You can have one file to do both. Simplest way is to do it with the python, but not the only way. All of my scripts have variable input.

  • If somethings are selected - it filters for the right type of item(s).
  • If nothing of the correct type is selected - it asks if I want to use everything in the view or everything in the project.

Makes it simple for the user.

The select node need to be defined as input so it will wait for the user to make a selection. This is what it is used in Dynamo Player.
image