Unload CAD Links

Hello, I’ve been trying to find a way to unload All CAD Links in the current document. Here is my code so far.

    ALLCADTypesInDocument =
        .Where(c => c.IsExternalFileReference())

    for type in ALLCADTypesInDocument:
        extFileRef = type.GetExternalFileReference()
        if (extFileRef == None or extFileRef.GetLinkedFileStatus() != LinkedFileStatus.Loaded) : 
        //type.Unload(positions) Not working... this method does not exist for cad link

This seems to get all link types… however… i couldn’t find a way to unload then. Is there a way to do so?

Thank you all in advance

Any tips?

I still have faith!

Hi Ramoon, retrieve the Id of the linked CADs and use Document.Delete(ElementId)

I dont want to remove the CAD Links from the document, only to unload then from the document.

ok, that’s a bit trickier. Have checked Revit Lookup before the link is unloaded and after the link is unloaded?

There is no direct method in the API to do that, so the only way to approach it is to check if there is anything changing in the DB.