Assign a new Assembly Code

Hi everyone,

I want to assign a Assembly Code to all the elements on my model, so far I have figured out how to obtain the current Assemble Code (blank) and made a dictionary with the Values that I want to assign, but for some reason a I can’t set it to the elements.

Any idea what am I missing? or if is there any other way to achieve this?

P.S. I also have a .txt file with all the element names and the assembly codes, it would save time if I somehow could make the Dictionary from that file.

Thanks

The error message should explain the issue. Assembly Code is a type parameter, so you need to get the FamilyType from the instances you’ve selected and set the parameter on the FamilyType.

You can certainly create a dictionary from a text file. That’s a much better solution than rewriting the mappings manually. Even better if you’ve formatted to csv. Just read the text file with FileSystem.ReadText to extract the names and values and write them to a new dictionary.

1 Like

@Nick_Boyts Thanks for your help, I changed to Family Type and it worked! but for some reason I can’t see all the family types that are in my model (eg. Conduit with fittings:ACM_CND_Tuberia_Cobre) any idea of why is that?

Can’t see the nodes you’re using in that screenshot (make sure you’re zoomed in enough that node titles are visible before taking screenshots) but I’m guessing you’re using the Family Type selector. That’s only going to show loadable families and their types. For system families like conduit, you’ll have to use another method. Try using the Element Classes (Element Types in older versions) and All Elements of Class (Type) nodes to work with system types.

@Nick_Boyts thanks again, I took a better Screenshot this time.

I used the Element Types Node and it worked but when I try to put it all together wit the Family Type list I get an Error on the Element Name and the Dictionary that says “Asked to convert non-convertible types”.

Any Idea how could I mix both types of families?

This usually means that a nodes is trying to do something to an invalid object type. In this case, you’re feeding the ElementType names rather than the elements themselves. You can get rid of these unnecessary nodes:


I’d also recommend using the flattened list for everything (which doesn’t need any list levels).

1 Like

That solved it! thanks :slight_smile:

Now I just noticed that it works when I’m rewritting the families manually, but not when I try to use the TXT file. Could you help me with that?

This is what I have:

As this is a new issue, completely independent of your first question, it’s best to start a new thread addressing the dictionary topic specifically. Before you do that, I’d suggest looking at how data and/or structure differs between the working version and the text version. If they don’t look the same, they aren’t likely to behave the same.

1 Like