.NET

.NET

Reply
Mentor
GeeHaa
Posts: 156
Registered: ‎04-14-2005
Message 1 of 5 (335 Views)

Finding the center point of a viewport in Modelspace

335 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 (311 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 (303 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")

Mentor
GeeHaa
Posts: 156
Registered: ‎04-14-2005
Message 4 of 5 (295 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

Mentor
GeeHaa
Posts: 156
Registered: ‎04-14-2005
Message 5 of 5 (289 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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
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.