Hi @GosponZ. Here is some untested code you can review to see if it makes sense to you. When there are multiple different models referenced by one drawing, it can really get confusing, and determining which one is the 'main' reference (if there is such a thing) can be challenging too. So, in this example, I am simply using the iLogic shortcut snippet to specify which 'model' is the main one (the main assembly). This may not be the most intuitive way to do it, but the main idea is the code following that point. If any view is referencing a 'model' document that can not be found within the 'AllReferencedDocuments' collection of the 'main' model, then delete that view, which should get rid of any unwanted references in the drawing...after an update/rebuild or two.
Dim oDDoc As DrawingDocument = ThisDoc.Document
Dim oModelDoc As Document = ThisDoc.ModelDocument
Dim oModelRefs As DocumentsEnumerator = oModelDoc.AllReferencedDocuments
For Each oSheet As Sheet In oDDoc.Sheets
For Each oView As DrawingView In oSheet.DrawingViews
Dim oViewDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
If oViewDoc Is oModelDoc Then Continue For
Dim oMatch As Boolean = False
For Each oModelRef As Document In oModelRefs
If oModelRef Is oViewDoc Then oMatch = True
Next
If oMatch = False Then oView.Delete
Next
Next
If oDDoc.RequiresUpdate Then oDDoc.Update2(True)
If oDDoc.Dirty Then oDDoc.Save2()
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)