Hello Everyone.
I have a routine that creates a new viewport from an existing entity, ie a circle or polyline or any other allowed class. My routine creates the viewport, but, it is always on and Inactive, and I cannot find a way to make it on and active. does anyone have any ideas?
Here is my code:
Public Function MakeVP(ByVal eID As ObjectId, ByVal Scale As String, ByVal PrimaryUnit As ePrimaryUnits, ByVal Locked As Boolean)
Dim OID As ObjectId
Dim DB As Database = HostApplicationServices.WorkingDatabase()
Dim Trans As Transaction = DB.TransactionManager.StartTransaction()
Try
Dim acVP As Viewport = New Viewport
Dim pCP As New Point3d
Dim AScale As AnnotationScale = ScaleManager.MakeScale(Scale, PrimaryUnit)
Dim bt As BlockTable = Trans.GetObject(DB.BlockTableId, OpenMode.ForRead)
Dim btr As BlockTableRecord = Trans.GetObject(bt(BlockTableRecord.PaperSpace), OpenMode.ForWrite)
acVP.NonRectClipEntityId = eID
acVP.NonRectClipOn = True
OID = btr.AppendEntity(acVP)
Trans.AddNewlyCreatedDBObject(acVP, True)
acVP = Trans.GetObject(OID, OpenMode.ForWrite, False, True)
acVP.Locked = Locked
acVP.CustomScale = IIf(PrimaryUnit = ePrimaryUnits.m, 1000.0 / CDbl(Scale), 1.0 / CDbl(Scale))
acVP.CustomScale = 20
acVP.On = True
acVP.AnnotationScale = AScale
Trans.Commit()
Catch aex As Autodesk.AutoCAD.Runtime.Exception
Microsoft.VisualBasic.Interaction.MsgBox("AutoCAD Exception (VIEWPORT): " & aex.Message, MsgBoxStyle.Exclamation)
Catch ex As System.Exception
Microsoft.VisualBasic.Interaction.MsgBox("System Exception: " & ex.Message, MsgBoxStyle.Exclamation)
Finally
Trans.Dispose()
End Try
End Function
Any help would be greatly appreciated.
Regards
Martin Duke