Current Space is Model or Layout


Detect Current Space (Model or Paper) Layout and Viewport

https://spiderinnet1.typepad.com/blog/2014/05/autocad-ne ... -model-or-paper-and-viewport.html

 <CommandMethod("TcTestModelAndLayout")> _
    Public Shared Sub TestSpaceAndViewport_Method()
        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor

        If IsInModel() Then
            ed.WriteMessage(vbLf & "In Model.")
        End If
        If IsInLayout() Then
            ed.WriteMessage(vbLf & "In Layout.")
        End If
        If IsInLayoutPaper() Then
            ed.WriteMessage(vbLf & "In Layout Paper.")
        End If
        If IsInLayoutViewport() Then
            ed.WriteMessage(vbLf & " In Layout Viweport.")
        End If
    End Sub
    Public Shared Function IsInModel() As Boolean
        If Application.DocumentManager.MdiActiveDocument.Database.TileMode Then
            Return True
        Else
            Return False
        End If
    End Function

    Public Shared Function IsInLayout() As Boolean
        Return Not IsInModel()
    End Function

    Public Shared Function IsInLayoutPaper() As Boolean
        Dim doc As Document =  Application.DocumentManager.MdiActiveDocument
        Dim db As Database = doc.Database
        Dim ed As Editor = doc.Editor

        If db.TileMode Then
            Return False
        Else
            If db.PaperSpaceVportId = ObjectId.Null Then
                Return False
            ElseIf ed.CurrentViewportObjectId = ObjectId.Null Then
                Return False
            ElseIf ed.CurrentViewportObjectId = db.PaperSpaceVportId Then
                Return True
            Else
                Return False
            End If
        End If
    End Function

    Public Shared Function IsInLayoutViewport() As Boolean
        Return IsInLayout() AndAlso Not IsInLayoutPaper()
    End Function



如何设定一个按钮用来暂停和继续一个循环?



欢迎关注微信公众账号ByCAD