![]() |
【转帖】如何在拖放操中取得鼠标松开时在cad下的座标?
如何在拖放操中取得鼠标松开时在cad下的座标?
www.dimcax.com 如何在拖放操中取得鼠标松开时在cad下的座标? 如标题所示。样例(第六课,可停靠对话框。)上也是后来再输入了一个点。我感觉这是个画蛇添足的做法。要是能取得这个点就好了。我的vb。net较菜望各位不吝赐教。 我想了想,此问题可简化为只需取出当时鼠档在cad中的位置座标(即cad左下角的实时变化的座标值)。此方法有没有人知道是什么命令?有的话烦请告诉我。。 [ cad开发爱好者 或有这个函数也可以。 将屏幕点转化为cad下的点。 vb开发cad extern static bool acedcoordfrompixeltoworld(int viewportnumber, system.drawing.point pixel, out autodesk.autocad.geometry.point3d worldpt); [dllimport("acad.exe", callingconvention = callingconvention.cdecl, entrypoint="?acedcoordfromworldtopixel@@yahhqbnaavcpoint@@@z")] extern static bool acedcoordfromworldtopixel(int viewportnumber, ref autodesk.autocad.geometry.point3d worldpt, out system.drawing.point pixel); [commandmethod("testpix")] public void test() { point3d pt = new point3d(0,0,0); system.drawing.point pix; acedcoordfromworldtopixel(0,ref pt,out pix); point3d res; acedcoordfrompixeltoworld(0,pix,out res); } } c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。 谢谢站长,感激涕零!我将其改为vb代码,有什么问题免不了还要麻烦站长。呵……真是太不好意思了。 只是我水平太差,没有能力将其改写成vb的,可否麻烦站长帮助改写或用什么方法让vb可以调用。 [ cad开发爱好者 cad开发爱好者 '''api函数如下所示: public class arxapi _ public shared function acedcoordfrompixeltoworld(byval viewportnumber as integer, byval pixel as system.drawing.point, byref point as point3d) as boolean ''' ''' end function ''' _ public shared function acedcoordfromworldtopixel(byval viewportnumber as integer, byval worldpt as point3d, byref pixel as system.drawing.point) as boolean ''' ''' end function end class '''调用函数如下: public overrides sub ondrop(byval e as system.windows.forms.drageventargs) dim position as point3d = new point3d(e.x, e.y, 0) showmessage(position.tostring) 'dim ed as editor = application.documentmanager.mdiactivedocument.editor 'position = ed.getpoint("in point:").value arxapi.acedcoordfrompixeltoworld(0, new point(e.x, e.y), position) showmessage(position.tostring) dim fiex as point = new point(0, 0) 'arxapi.acedcoordfromworldtopixel(0, position, fiex) showmessage(fiex.tostring) end sub cad开发爱好者 不过将cad点转为屏幕点的函数好像不对。站长您能不能帮我看一下有什么不对的? cad开发爱好者 1 |
| 所有的时间均为北京时间。 现在的时间是 08:10 AM. |