.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Paperspace ViewPort TwistAngle question

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
1048 Views, 4 Replies

Paperspace ViewPort TwistAngle question

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?


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(pVprt.ViewCenter.X, pVprt.ViewCenter.Y, 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

Thanks,

Gagan
==============
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

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
Message 3 of 5
Anonymous
in reply to: Anonymous

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?
>


Anyone please? How to twist a viewport around a given point in WCS?

Thank you!

Gagan
=================
Message 4 of 5
cadMeUp
in reply to: Anonymous

Maybe you can try (this is in C# but similar to VB):
{code}

Extents3d pExtents = pNorthArrow.GeometricExtents;
Point3d p1 = pExtents.MinPoint;
Point3d p2 = pExtents.MaxPoint;
Point3d midPoint = new Point3d((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2, (p1.Z + p2.Z) / 2);

pVprt.ViewHeight = pExtents.MaxPoint.Y - pExtents.MinPoint.Y;
pVprt.ViewDirection = Vector3d.ZAxis;
pVprt.ViewTarget = midPoint;
pVprt.ViewCenter = Point2d.Origin;
pVprt.TwistAngle = Math.PI / 2;

{code}
Message 5 of 5
Anonymous
in reply to: Anonymous

cadmeup wrote:
> Maybe you can try (this is in C# but similar to VB):
> {code}
>
> Extents3d pExtents = pNorthArrow.GeometricExtents;
> Point3d p1 = pExtents.MinPoint;
> Point3d p2 = pExtents.MaxPoint;
> Point3d midPoint = new Point3d((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2, (p1.Z + p2.Z) / 2);
>
> pVprt.ViewHeight = pExtents.MaxPoint.Y - pExtents.MinPoint.Y;
> pVprt.ViewDirection = Vector3d.ZAxis;
> pVprt.ViewTarget = midPoint;
> pVprt.ViewCenter = Point2d.Origin;
> pVprt.TwistAngle = Math.PI / 2;
>
> {code}

Thanks a lot, cadmeup! This one worked. I was setting ViewCenter same as
ViewTarget, which was the reason.

Gagan
==========

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost