Active Member
Posts: 9
Registered: ‎11-19-2008
Message 1 of 1 (185 Views)

Viewport.ViewCenter doesn't seem to work ok if Viewport.TwistAngle is not 0

185 Views, 0 Replies
12-03-2008 02:59 AM
what not right

Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry

Public Class Test
Public Sub Test()
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim ed As Autodesk.AutoCAD.EditorInput.Editor
ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = db.TransactionManager
Dim trans As Autodesk.AutoCAD.DatabaseServices.Transaction = tm.StartTransaction
Dim lid As ObjectId
Dim LayoutDictionary As DBDictionary = tm.GetObject(db.LayoutDictionaryId, OpenMode.ForRead, False)
If LayoutDictionary.Contains("1") Then
lid = LayoutDictionary.Item("1")
lid = LayoutManager.Current.CreateLayout("1")
End If
LayoutManager.Current.CurrentLayout = "1"

Dim Layout As Layout = tm.GetObject(lid, OpenMode.ForWrite, False)
Dim Viewport As Viewport = tm.GetObject(Layout.GetViewports(1), Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite, False)
Viewport.Locked = False
Viewport.TwistAngle = -0.89382539718635012

Viewport.Width = 500
Viewport.Height = 300.0
Viewport.CenterPoint = New Point3d(13, 25, 0)
Viewport.ViewCenter = New Point2d(500, 400) ' not 500,400 bat ViewCenter =X= 1.4576 Y= 640.0352
Viewport.CustomScale = 2

Viewport.Locked = True
Viewport.On = True


Catch e As System.Exception
End Try
End Sub
End Class
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.