给你贴篇ADN文章,把DWG坐标转换成屏幕象素坐标
 - <normalfont>
- Translating DWG coordinates to screen coordinates
- ID 42345
- Applies to: AutoCAD 2000
- AutoCAD 2000I
- AutoCAD 2002
-
- Date 1/22/2002
-
- This document is part of Coordinates and Transformations ObjectARX COM-ActiveX Interfaces
- Question
- Can I get the screen (Windows) coordinates from the DWG coordinates using VBA to
- show a UserForm with its position set exactly on the position of an object in
- the .DWG?
- Answer
- Although you cannot do this in VBA, you can use the Win32 API and ObjectARX.
- ObjectARX has functions that allow you to convert points from client windows to
- .DWG points. You can create wrapper functions around them and export them. Make
- sure you use VB-acceptable database types, and use the __stdcall calling
- convention. It is suggested that you place the .ARX file in your installed
- AutoCAD directory in order to make it easy to resolve the path to find such a
- file for a VBA or VB application.
- In VBA or VB, you can declare the exported functions from the .ARX file just as
- all other functions from the Win32 API libraries. Now you can use them as if
- they areVBA ot VB functions, but make sure that the .ARX file is loaded.
- Two sample applications are attached; one in VC++ and another in VBA, that show
- you how to do the above. If you prefer not to use the VC++ code, copy the
- ..\release\asdktransformpts.arx file to your installed AutoCAD directory.
- Notice that the translated coordinates are relative to the AutoCAD frame window.
- If you want screen (desktop) points, use CWnd::ClientToScreen() to convert them.
- </normalfont>
下面附件是例子代码 |