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
[本日志由 tiancao1001 于 2019-09-12 11:27 PM 编辑]
|
暂时没有评论
发表评论 - 不要忘了输入验证码哦! |