Posts: 4
Registered: ‎10-10-2013
Message 1 of 2 (172 Views)
Accepted Solution

Get pixel size in current view

172 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

Posts: 25
Registered: ‎09-28-2004
Message 2 of 2 (163 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:

You are not logged in.

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

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