I have programmed for years with lisp, visual lisp, and vba for years, but am just now getting started using vb.net in autocad (as will be obvious by the code and the question).
I am trying to find the annotation scale of all viewports in the drawing. The code below selects all viewports in the drawing and cycles through them, allowing me to get the properties of each one, however, I'm having a hard time excluding the paperspace viewport. I thought I could identify it as the viewport with the blockname property = "*Paper_Space", but that didn't work.
Suggestions are appreciated.
Mike
<CommandMethod("SSVP")> _
Public Sub SSVP()
Dim myDB As DatabaseServices.Database
Dim myDWG As ApplicationServices.Document
Dim myEd As EditorInput.Editor
Dim myPSR As EditorInput.PromptSelectionResult
Dim mySS As EditorInput.SelectionSet
Dim mySelectedObject As EditorInput.SelectedObject
Dim myFilter(0) As DatabaseServices.TypedValue
Dim iIndex As Integer
Dim myTransMan As TransactionManager
Dim myTrans As Transaction
Dim myViewport As Viewport
myFilter(0) = New DatabaseServices.TypedValue( _
DatabaseServices.DxfCode.Start, "VIEWPORT")
Dim mySF As New EditorInput.SelectionFilter(myFilter)
Dim myAcadEnt As DatabaseServices.Entity
myDWG = ApplicationServices.Application.DocumentManager.MdiActiveDocument
myDB = myDWG.Database
myEd = myDWG.Editor
myPSR = myEd.SelectAll(mySF)
mySS = myPSR.Value
iIndex = mySS.Count - 1
myTransMan = myDWG.TransactionManager
myTrans = myTransMan.StartTransaction
For iIndex = 0 To mySS.Count - 1
mySelectedObject = myPSR.Value.Item(iIndex)
myAcadEnt = mySelectedObject.ObjectId.GetObject(DatabaseServices.OpenMode.ForRead)
myViewport = mySelectedObject.ObjectId.GetObject(OpenMode.ForRead)
If myViewport.BlockName = "*Paper_Space" Then
Debug.Print("Paperspace viewport")
Else
Debug.Print(myViewport.AnnotationScale.Scale)
End If
Next
myTrans.Dispose()
myTransMan.Dispose()
MsgBox(mySS.Count)
End Sub