.NET

Reply
Distinguished Contributor
GeeHaa
Posts: 150
Registered: ‎04-14-2005
Message 1 of 5 (258 Views)

Finding the center point of a viewport in Modelspace

258 Views, 4 Replies
10-03-2013 02:42 PM

Hi

 

I need to find the center point of a viewport in modelspace. I am looking for a vb.Net example but I can't seem to locate one.

 

Thanks in advance

New Member
jrneyulu
Posts: 2
Registered: ‎10-04-2013
Message 2 of 5 (234 Views)

Re: Finding the center point of a viewport in Modelspace

10-04-2013 01:38 AM in reply to: GeeHaa

Hi,

 

You can find the center point of hte Model space by using variable VIEWCTR

 

 

New Member
jrneyulu
Posts: 2
Registered: ‎10-04-2013
Message 3 of 5 (226 Views)

Re: Finding the center point of a viewport in Modelspace

10-04-2013 02:17 AM in reply to: GeeHaa

Hi,

 

We can find the same in c# dot net also as shown in below

Application.GetSystemVariable("VIEWCTR")

Distinguished Contributor
GeeHaa
Posts: 150
Registered: ‎04-14-2005
Message 4 of 5 (218 Views)

Re: Finding the center point of a viewport in Modelspace

10-04-2013 06:37 AM in reply to: jrneyulu

Thanks for the response. I guess what I am looking for is a way to get the Modelspace centerpoint for each viewport in a layout without making the viewport or layout active. I have the viewports as a collection of object Ids. I was looking at the viewport viewcenter property. It seems to work for about 90% of our drawings but if someone has messed with the DView command the view center is off. I'm thinking there must be a way to use a transformation matrix to convert the DCS point to WCS

 

Thanks Again

Distinguished Contributor
GeeHaa
Posts: 150
Registered: ‎04-14-2005
Message 5 of 5 (212 Views)

Re: Finding the center point of a viewport in Modelspace

10-04-2013 09:00 AM in reply to: GeeHaa

This seems to work. I hope I did it right

 Dim ptCenter As Point3d = New Point3d(myVP.ViewCenter.X, myVP.ViewCenter.Y, 0)
 Dim transMatrx As Matrix3d
 transMatrx = Matrix3d.WorldToPlane(myVP.ViewDirection)
 transMatrx = Matrix3d.Displacement(myVP.ViewTarget - Point3d.Origin) * transMatrx
 transMatrx = Matrix3d.Rotation(-myVP.TwistAngle, myVP.ViewDirection, myVP.ViewTarget) * transMatrx
 ptCenter = ptCenter.TransformBy(transMatrx)

 Thanks Again

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community