.NET

Reply
F32
Member
F32
Posts: 4
Registered: ‎10-10-2013
Message 1 of 2 (222 Views)
Accepted Solution

Get pixel size in current view

222 Views, 1 Replies
10-10-2013 02:28 AM

How can I get the pixel size in current view?

i.e., how many meters a pixel's width in the current view stands for

Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Point2d screenSize = (Point2d)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("SCREENSIZE");
System.Drawing.Point upperLeft = new System.Drawing.Point(0, 0);
System.Drawing.Point lowerRight = new System.Drawing.Point((int)screenSize.X,(int)screenSize.Y);
Point3d upperLeftWorld = ed.PointToWorld(upperLeft, 0);
Point3d lowerRightWorld = ed.PointToWorld(lowerRight, 0);

 The variable Scrrensize gives you the size of the current view in Pixel.

The PointToWorld Function gives you the "bounding box" of the screen in World Coordinates.

 

With this data you should be able to calculate everything you want :smileyhappy:

Contributor
Matti72
Posts: 25
Registered: ‎09-28-2004
Message 2 of 2 (213 Views)

Re: Get pixel size in current view

10-10-2013 03:16 AM in reply to: F32
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
			Editor ed = doc.Editor;

			Point2d screenSize = (Point2d)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("SCREENSIZE");

			System.Drawing.Point upperLeft = new System.Drawing.Point(0, 0);
			System.Drawing.Point lowerRight = new System.Drawing.Point((int)screenSize.X,(int)screenSize.Y);

			Point3d upperLeftWorld = ed.PointToWorld(upperLeft, 0);
			Point3d lowerRightWorld = ed.PointToWorld(lowerRight, 0);

 The variable Scrrensize gives you the size of the current view in Pixel.

The PointToWorld Function gives you the "bounding box" of the screen in World Coordinates.

 

With this data you should be able to calculate everything you want :smileyhappy:

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.