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

Finding the center point of a viewport in Modelspace

4 REPLIES 4
Reply
Message 1 of 5
GeeHaa
1727 Views, 4 Replies

Finding the center point of a viewport in Modelspace

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

4 REPLIES 4
Message 2 of 5
jrneyulu
in reply to: GeeHaa

Hi,

 

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

 

 

Message 3 of 5
jrneyulu
in reply to: GeeHaa

Hi,

 

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

Application.GetSystemVariable("VIEWCTR")

Message 4 of 5
GeeHaa
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

Message 5 of 5
GeeHaa
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

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