sendstringtoexecute后如何立即获取实体id?
www.dimcax.com
sendstringtoexecute后如何立即获取实体id?
sendstringtoexecute绘制实体之后,立即调用autodesk.autocad.editorinput.editor.selectlast(),获得实体id,应该如何实现?代码见3楼。谢谢! [ 由 yi_li
你通过sendstringtoexecute发送命令来绘制实体吗?
是的,想sendstringtoexecute发送命令绘制实体之后,立即得到实体id,利用id设置该实体图层及颜色。试了几次,没有得到,请教了。 c++中有个acedgetlastent,c#中autodesk.autocad.editorinput.editor.selectlast(),两个函数否对应?如下代码,没有成功,请大家帮我看下该如何办?而且发送命令后并没有立即更新数据库,导致我得不到立即绘制的实体。 public objectid createarc2() { editor ed = tools.editor; //第一点----------------- promptpointoptions opt1 = new promptpointoptions("请指定第一点"); point3d pt1 = ed.getpoint(opt1).value; //第二点 opt1.message = "\n请指定第二点"; opt1.usebasepoint = true; opt1.basepoint = pt1; point3d pt2 = ed.getpoint(opt1).value; //第三点 opt1.message = "\n请指定第三点"; point3d pt3 = ed.getpoint(opt1).value; string str1 = pt1.x.tostring() + "," + pt1.y.tostring(); string str2 = pt2.x.tostring() + "," + pt2.y.tostring(); string str3 = pt3.x.tostring() + "," + pt3.y.tostring(); tools.sendcommand("arc",str1,str2,str3);/////该命令与sendstringtoexecute一回事 messagebox.show(ed.selectlast().value.tostring()); return ??? //////这里该如何办呢? } [ 由 yi_li
用你的方法,直接得到id是不可能的。你为什么要用sendcommand呢?创建实体,有现成的函数呀!
原因有二: 1、直接利用函数,需要打开数据库,每次启动事务、关闭事务烦索;采用这种方法直观,可直接利用cad命令,跟手工绘图没什么区别。 2、象arc函数,需要输入的是圆心角,而cad命令画弧有七种方法,可直接利用,无需再作角度转换计算。
数据库处理方式是最合理的!用sendcommand想得到id,还是一样要用事务处理,更加麻烦,还是老老实实用现成的函数吧!
原帖由 yi_li 原因有二: 1、直接利用函数,需要打开数据库,每次启动事务、关闭事务烦索;采用这种方法直观,可直接利用cad命令,跟手工绘图没什么区别。 2、象arc函数,需要输入的是圆心角,而cad命令画弧有七种方法,可直接利 ...
你可以构建一些类,与cad命令一样的功能也是很简单的,不要说七种,七十种都可以,只要你喜欢怎样画弧,就怎样画弧,哈哈!