Avoiding Family Renaming With Copy Elements API

Avoiding Family Renaming With Copy Elements API

kirsch33
Contributor Contributor
372 Views
2 Replies
Message 1 of 3

Avoiding Family Renaming With Copy Elements API

kirsch33
Contributor
Contributor

Hi all, I am working on a plugin which basically will copy/replace/update drafting views in the current project with our Master Detail revit file. To do this, I am using the copyelements API like so:

 

def copy_elements(dest, source, elements):
    class CustomCopyHandler(IDuplicateTypeNamesHandler):
        def OnDuplicateTypeNamesFound(self, args):
            return DuplicateTypeAction.UseDestinationTypes

    transform = Transform.Identity
    cpOptions = CopyPasteOptions()
    cpOptions.SetDuplicateTypeNamesHandler(CustomCopyHandler())

    new_element_ids = ElementTransformUtils.CopyElements(source, elements, dest, transform, cpOptions)

    return new_element_ids

 

However, even with the above code I sometimes still get warning about families being renamed due to conflict with the version loaded into the library file. The warning is this:

 

https://www.revitapidocs.com/2020/f91a433b-d41a-92f5-1512-d10776211150.htm?section=seeAlsoToggle

 

How can I avoid this error/warning? I don't want to just suppress the message, I want to use the families/types loading into the Master Detail file rather than the ones being sent. I do not like ending up with multiple versions of a detail family with "1", "2", etc as a result of the automatic renaming from this error.

0 Likes
373 Views
2 Replies
Replies (2)
Message 2 of 3

JulioPolo
Participant
Participant

Running into the same issue. Did you find any solution?

0 Likes
Message 3 of 3

TripleM-Dev.net
Advisor
Advisor

Hi,

 

If revit detects the existing family differs from the one pasted, it will create the 1, 2 etc to keep the families loaded in as-is, the family in the project could be different.

 

Often they are not different and just by a upgrade (project is R2024 and family is R2022) or additional type added in the Family editor will trigger this.

Only way around it is to first load the families themself from the Master file into the project (if the family in the project was edited this will then be lost.)

But could also happen with FilledRegions, materials etc...

 

Or the otherway around (i assume the master is read-only), load the families from the project into the Master before copying them.

 

I assume the items copied are groups with families in them?

If not and you're only copying Detail components, test if a family already exist in project and create/update the type in the project with the type properties from the family in the Master.

May need additional work if components need to be at certain position from another.

 

Really depends on what the workflow actually is. Whole details or just detail components.

 

- Michel

0 Likes