DisplayLocked Example

Using Programming Languages other than VBA

Sub Example_DisplayLocked()
	' This example scans the current drawing paper space Viewports
	' and displays whether or not any of them are locked.

	Dim pviewportObj As Object
	Dim msg As String, ClippedState As String
   
	' Make sure this drawing contains paper space viewports before continuing
	If ThisDrawing.PaperSpace.count = 0 Then
		MsgBox "There are no paper space viewports in the current drawing."
		Exit Sub
	End If

	' Go through each paper space viewport object in the drawing paper space
	' and determine whether or not it is locked

	For Each pviewportObj In ThisDrawing.PaperSpace
	
		' Determine whether this is a paper space viewport
		If TypeName(pviewportObj) = "IAcadPViewport" Then
		
			' Determine whether this paper space viewport is locked
			ClippedState = IIf(pviewportObj.Clipped, " is locked", " is not locked")
			msg = msg & "PViewport ID " & pviewportObj.objectID & ClippedState & vbCrLf
	
		End If

	Next

	' Display locked state of paper space Viewports
	MsgBox msg
End Sub

 

   Comments?