Pt1 = ScreenFromDrawingPoint(ucsMat, hWnd, first, vp) Now calculate the selected corners in screen coordinates And then the handle to the current drawing window Get the current UCS matrix (would be indentify if in WCS) Generate screen coordinate points based on the "\nSelect second point of capture window: " , Ask the user for the screen window to captureĮd.GetPoint( "\nSelect first point of capture window: " ) Command to capture a user-selected portion of a drawingĪcApp. Command to capture the main and active drawing windowsĪcApp. Static extern bool ClientToScreen( IntPtr hWnd, ref Point pt) For the coordinate tranformation we need.ĮntryPoint= extern int acedCoordFromWorldToPixel(
#AUTOCAD LISP GET VARIABLE FROM CLIPBOARD CODE#
Here’s the updated C# code with our new WSS command: Once we have the corners in screen coordinates, the code from last time can be used: with a few modifications to support selection of top-right/bottom-left corners, rather than the assumed top-left/bottom-right, as well as adding support for placing the bitmap on the clipboard, rather than saving it to a file. We need to do this for both corners of our user-selected window, of course. For this we need to P/Invoke the Win32 API function ClientToScreen().
#AUTOCAD LISP GET VARIABLE FROM CLIPBOARD WINDOWS#
Transform the WCS point into Windows client coordinates.Transform the selected point by the current UCS matrix to get WCS.To transform from UCS to screen coordinates we actually need three steps (and thanks to Adam Nagy, from DevTech EMEA, for creating code I borrowed from to get this working): The technique shown in today’s post is actually pretty handy for other situations: it’s quite common to want to transform a point from drawing coordinates (which may well be in a specific User Coordinate System (UCS)) into screen coordinates, especially when wanting to display a window or a custom context menu at the cursor location. This is actually a really useful tool for me when I’m writing this blog, so there was certainly a degree of self-interest involved. Following on from this recent post – and inspired by a question we received recently from a developer – I decided to extend the previous code to allow a user to select a portion of a drawing they would like to save to a file or place on the clipboard.