Gagan Gajabaharia wrote:
> I am trying to apply TwistAngle to a paperspace ViewPort. The ViewPort
> resides and comes from an external database. The documentation states
> that the viewport twist occurs around the line of sight, i.e. a line
> connecting the camera and the target. What happens is that the viewport
> twist doesn't give expected results. I think the problem is due to not
> specifying the camera location. Is there a way to specify camera
> location for a ViewPort - or am I doing something wrong in the code?
>
> Here's the code, can someone explain what is going on or wrong?
>
>
I have updated the code as below: ViewDirection, which represents
VIEWDIR system variable, is camera location specified 3D offset from
target point. So, the viewport ViewDirection should be a vector(0,0,1).
But still, I am not getting the correct result. Seems that viewport
twist is occurring around the target point (0,0).
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
Autodesk.AutoCAD.DatabaseServices.Viewport = DirectCast(pDbObj, Viewport)
If (pVprt.Height = 6.4 AndAlso pVprt.Width = 8.4) Then
Dim pExtents As Extents3d =
pNorthArrow.GeometricExtents()
pVprt.ViewCenter = New
Point2d((pExtents.MinPoint.X + pExtents.MaxPoint.X) / 2.0, _
(pExtents.MinPoint.Y + pExtents.MaxPoint.Y) / 2)
Dim tsHeight As Double = pExtents.MaxPoint.Y -
pExtents.MinPoint.Y
pVprt.ViewHeight = tsHeight
pVprt.ViewDirection = New Vector3d(0.0, 0.0,
1.0) 'plan view
pVprt.ViewTarget = New
Point3d(pVprt.ViewCenter.X, pVprt.ViewCenter.Y, 0.0)
pVprt.TwistAngle = Math.PI / 2
End If
End If
End While