Imports ZwSoft.ZwCAD.ApplicationServices
Imports ZwSoft.ZwCAD.DatabaseServices
Imports ZwSoft.ZwCAD.EditorInput
Public Class ZwcadApp
<CommandMethod("blockORxref")> _
Public Sub blockORxref()
Dim ZcDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim ZcDB As Database = ZcDoc.Database
Dim ZcEd As Editor = ZcDoc.Editor
Using ZcTran As Transaction = ZcDB.TransactionManager.StartTransaction()
Dim ZcBTR As BlockTableRecord = Nothing
Dim objId As ObjectId = ObjectId.Null
Do
Dim peo As New PromptEntityOptions(vbLf & "Select a block reference or an external reference:")
peo.SetRejectMessage(vbLf & "Must be a block reference or an external reference.")
peo.AddAllowedClass(GetType(BlockReference), True)
Dim per As PromptEntityResult = ZcEd.GetEntity(peo)
If per.Status <> PromptStatus.OK Then
Return
End If
Dim br As BlockReference = DirectCast(ZcTran.GetObject(per.ObjectId, OpenMode.ForRead), BlockReference)
ZcBTR = DirectCast(ZcTran.GetObject(br.BlockTableRecord, OpenMode.ForRead), BlockTableRecord)
If ZcBTR.IsFromExternalReference Then
objId = br.BlockTableRecord
if ZcBTR.IsFromOverlayReference then
ZcEd.WriteMessage(vbLf & "The object is an overlay
reference.")
else
ZcEd.WriteMessage(vbLf & "The object is an attacment reference.")
end if
Loop While ZcBTR Is Nothing '(or) Loop Until Not ZcBTR Is Nothing
If objId <> ObjectId.Null Then
ZcEd.WriteMessage(vbLf & "The object is an external reference.")
Else
ZcEd.WriteMessage(vbLf & "The object is a block reference.")
End If
ZcTran.Commit()
End Using
End Sub
End Class