判断一个外部参照是overlay还是attachment。

来源:互联网 发布:adobe软件打不开 编辑:程序博客网 时间:2024/05/01 12:23
Imports ZwSoft.ZwCAD.Runtime
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.IsFromExternalReferenceThen

                    objId = br.BlockTableRecord

if ZcBTR.IsFromOverlayReferencethen

  ZcEd.WriteMessage(vbLf & "The object is an overlay reference.")
           else

  ZcEd.WriteMessage(vbLf & "The object is an attacment reference.")

end if
         

                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
0 0