Are there code examples from the Autodesk docs that show the use of
GetEnumerator()/MoveNext()/Current?
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009
http://www.acadxtabs.com
Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
"Gagan Gajabaharia" wrote in message
news:6227427@discussion.autodesk.com...
Gagan Gajabaharia wrote:
> I would like to access all the viewports defined in the paperspace. Can
> someone point out a sample code that shows how to do that?
>
> Thanks! Gagan.
Never mind, I found the solution in the recently put online .NET ARX
help document:
_
Public Sub DoVports3()
'' Get the current document and database, and start a transaction
Dim acDoc As Document =
Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Using acTrans As Transaction =
acCurDb.TransactionManager.StartTransaction()
'' Open the Block table for read
Dim acBlkTbl As BlockTable
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
OpenMode.ForRead)
'' Open the Block table record Paper space for write
Dim acBlkTblRec As BlockTableRecord
acBlkTblRec =
acTrans.GetObject(acBlkTbl(BlockTableRecord.PaperSpace), OpenMode.ForRead)
'' Switch to the previous Paper space layout
Application.SetSystemVariable("TILEMODE", 0)
acDoc.Editor.SwitchToPaperSpace()
' Enumerate the BTR
Dim pBTREnum As BlockTableRecordEnumerator =
acBlkTblRec.GetEnumerator()
While (pBTREnum.MoveNext())
Dim pObjId As ObjectId = pBTREnum.Current
Dim pDbObj As DBObject = acTrans.GetObject(pObjId,
OpenMode.ForWrite, False, True)
If (TypeOf pDbObj Is Viewport) Then
Dim pVprt As Viewport = DirectCast(pDbObj,
Viewport)
End If
End While
'' Save the new objects to the database
acTrans.Commit()
End Using
End Sub