Translation - Mass change of all Family Types

I am new to Dynamo and want to get better. This script works for small projects, but not for larger projects.

The objective : to have all Generic Annotation families in a project with types ending in “- ANG” to be changed to “- FRA” when the project information parameter LANGUE is set to “FRA” (and vice versa, if the parameter is set to ANG).

Also how do I create a statement that says, IF the project information parameter says FRA, THEN the switch from ANG-FRA will happen. While also saying, IF the project information parameter says ANG, THEN the switch from FRA-ANG will happen.

I would appreciate feedback on this script to see what I can improve in my dynamo script writing.

Hi Mason,
You have certainly chosen a steep learning curve
Things to consider:

  • You will have to create pairs of types to reference
  • Then for each instance of a type based on the extension, swap the type based on the language
  • Type naming will have to be quite strict as there maybe types from other families with the same name

Please note that it is best to export the graph by zooming in so text is legible and using the ‘Export as Image > Workspace’ or the :camera: icon at the top right - this will capture the full graph with detail

Example below which builds a reference dictionary of families which has dictionaries of types with ANG or FRA suffixes.

Note that a road block you will encounter here is groups which do not support changes in the API. I would consider reloading the alternate language families over each other vs load/swap all instances due to this. Hopefully they use the same type names.

1 Like

Hi Mike,

Thank you for providing this script, it has been helpful. However, I have gotten it to work smoothly yet.

When swapping the family type from the opposing language, why is it necessary to “String.Remove” or “String.substring” certain inputs? If this is related to the number of Generic Annotations in the project? If so, would I have to change these values each time I added an additional “Generic Annotation” to the project?

Thanks!

These actions are related to manipulating the names of the families and types to build the dictionary keys - it does not create new types

I am creating a key for the main dictionary of Family - Family Type to be able to do this I have removed the last 4 characters of the type and joined to the family name with a hyphen as colons don’t work

I am also creating the ANG & FRA keys by taking a substring of the last three characters of the type name

Hi Mike,

By narrowing down the family types that are being selected to be swapped (which is the reality in our case), I was able to create a Dictionary for each of the families that include ElementTypes that include “QC - FRA” and “QC - ANG” (The name of the two types inside each bilingual generic annotation family).

This seems to have organized it in two indexes @ level 01:
0 - Dictionary
1 - Dictionary

From there, I would like the values to swap from each Dictionary. This is where I am stuck.

Thanks again for all your time,

You are trying to change a family type to another family type which is not possible with the node, and as far as I know this is not possible with the API - what you can do is change the type of a family instance

You will need to collect all of the generic tags (family instances), filter those that you would like to change and swap their type (using the type id). You will need to have the family name and family type name to swap as keys

Is there a way to swap the values of two lists? For example, the list above is FRA. So, when the language parameter is set to ANG, I would like each of the indexes in each lists to “swap”. The first item in the FRA list becomes the first item in the ANG list.

I am just looking to “swap” ID for ID based on 2 lists. But each time I try and change the parameter value for “Type Name” it does not work (which like you said is impossible) but how else could I change the Family Type, if I am unable to change the value for the Type Name parameter?

For a general case, I think you’d want a dictionary mapping the FRA names to ANG types and the ANG names to FRA types. Then you could just get the names from your list of elements and have the dictionary spit out the respective family to convert to.

However for your specific workflow, since your types have the same name except for the identifier and the value should be based on a set parameter, you could just replace the first 3 characters of the type name with the correct identifier (FRA or ANG) and get the family types from those names.

The answer is in your question. The type name just comes from the assigned family type. If you want to change the type, you have to change the actual Family Type. This is also a parameter and takes an element (the family type) as an argument.