Change family and type of imported IFC elements

Hello.
I opened an ifc file in revit (file -> open -> open ifc) , and it placed a bunch of duct families in my project browser.

As far as I can understand it made a family and type for every element.
in the project browser it looks like this :
family: duct , type:duct
family:duct1 , type:duct1
family:duct2 , type:duct2 …

Im trying to regroup all these elements so they are all in their correct families and types (family: duct , type: duct)
I made a dynamo script that reads the parameter “Type and family” parameter from element and sets in on another one (tried it with native Revit elements, it worked).

When I used it on these imported ifc elements, I managed to change the family and type of an element, but he then disappeared.

project browser of imported families:
Capture
dynamo script:


How it looks in model after using the script (the big duct got changed to family and type of small duct):

When I select elements from the project browser by going to the type ->select all instances I get 2 elements (meaning the change worked), but when I try to access it via schedule (highlight in view) it keeps highlighting the element from which I took the Family and type parameter.
I tried changing more ducts and if I select any of them in schedule it always highlight the original.

I cant figure out what is going on, does any1 have experience with these kinds of families that are auto generated when importing from ifc?

An update, i found the missing elements. It literary changed them into the same element and set them on the same position. Now i have 7 ducts at the same place.

So is it even possible to change the family of these strange elements?

If I understand correctly, you want to create legit types and families from an ifc file?

You don’t have to use dynamo for this, just use the link ifc, and open the automatically generated rvt file. This linking method uses the newer directshape api, while the opening method uses an older one. Directshape objects behaves more similarly to generic revit objects.

I’ve written about working on ifc files with revit here: https://infeeeee.github.io/revit/import-ifc.html

Ifc has different schemas for ifcPipe and ifcPipeFittings, and revit should import them to the correct category, so maybe it would be easier to set this up in the original program, before exporting to ifc?

No i dont want to create legit families, i want (for example) to place all existing ducts into a single family and type in the project browser (and delete all of the other ones with numbers). I opened the ifc file “the old way” from your post. I will try the suggested way and see what i get. Thanks for your input.