.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Detach XRefs

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
gwhitcherQ98HZ
179 Views, 2 Replies

Detach XRefs

I have been trying to detach the Xrefs in a list of drawings and had no success.  I open each one then I use this code. It does hit the db.detachXref(oid) line. No errors but does not detach it.

 

 doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
                ed = doc.Editor
                db = doc.Database
                Using lk As DocumentLock = doc.LockDocument()
                    Using tr As Transaction = db.TransactionManager.StartTransaction()
                        Dim bt As BlockTable = TryCast(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
                        For Each oid As ObjectId In bt
                            Dim btr As BlockTableRecord = CType(tr.GetObject(oid, OpenMode.ForRead), BlockTableRecord)
                            If btr.IsFromExternalReference Then
                                db.DetachXref(oid)
                            End If
                        Next
                    End Using
                End Using

 

2 REPLIES 2
Message 2 of 3
fieldguy
in reply to: gwhitcherQ98HZ

you are missing tr.Commit() before end using

Message 3 of 3

How did I miss that! Thank you!

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

Post to forums  

Forma Design Contest


AutoCAD Beta