好的,可能只是星期一,但我无法让这段代码工作
- Public Sub VPzXP()
- On Error GoTo ERR_CONTROL
- Dim vp As AcadPViewport
- Dim N As Double
- Dim gpCode(0) As Integer
- Dim dataValue(0) As Variant
- Dim OBJSELSET As AcadSelectionSet
- gpCode(0) = 0
- dataValue(0) = "VIEWPORT"
- Set OBJSELSET = ThisDrawing.SelectionSets.Add("VPL")
- OBJSELSET.Select acSelectionSetAll, , , gpCode, dataValue
-
- For Each vp In OBJSELSET
- If vp.DisplayLocked = True Then
- vp.DisplayLocked = False
- End If
- ThisDrawing.MSpace = True
- ZoomExtents
- N = CDbl(ThisDrawing.GetVariable("DIMSCALE"))
- N = 1 / N
- ZoomScaled N, 2
- ThisDrawing.MSpace = False
- vp.DisplayLocked = True
- Next
- Exit_Here:
- Exit Sub
- ERR_CONTROL:
- Select Case Err.Number
- Case "-2145320851"
- ThisDrawing.SelectionSets.Item("VPL").Delete
- Err.Clear
- Resume
- Case Else
- MsgBox Err.Number
- Err.Clear
- Resume Exit_Here
- End Select
- End Sub
如果我单步执行,它在第一次通过时有效,但Acad希望再次处理VP,并缩放范围,然后退出
有人知道为什么吗?
|