VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cannot Detach XRef

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
meck
1556 Views, 2 Replies

Cannot Detach XRef

HI All,

I've search and tried every piece of code I could find on here to detach XRefs but none of them have worked for me. When I run the code below it does not find any Xrefs to detach. There are no frozen or locked layers.

 

Dim oBlock As AcadBlock

For Each oBlock In ThisDrawing.Blocks
    If oBlock.IsXRef Then
        oBlock.Detach
    End If
Next

 

Attached is a drawing with the Xrefs that I cannot detach.

Any help would be greatly appreciated!

 

FYI AutoCAD 2013, Win 7

Mike Eck
Master Drafter/ CAD Programmer
Using Inventor 2018
2 REPLIES 2
Message 2 of 3
Alfred.NESWADBA
in reply to: meck

Hi,

 

your drawings showes referenced images, but not referenced drawings, so not really XRef's.

You can use this code >>>here<<< to remove image-references from a drawing.

 

Good luck, - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 3
meck
in reply to: Alfred.NESWADBA

Thanks!

I was getting an error on the line "oSset.SelectOnScreen dxfCode, dxfValue". As it turns out I didn't need that part of the code. The final code looks like this...

Sub DeleteImages()
    Dim oEnt As AcadEntity
    Dim oDict As AcadDictionary
    Set oDict = ThisDrawing.Dictionaries("ACAD_IMAGE_DICT")

    If oDict.Count > 0 Then

        Dim oImageDef As Object
       
        For Each oImageDef In oDict
            oImageDef.Delete
        Next
    End If
   
    Set oDict = Nothing
End Sub

Mike Eck
Master Drafter/ CAD Programmer
Using Inventor 2018

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost