几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » ObjectARX(VB.NET/C#)
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-20, 09:50 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】大家帮我看看这个jig的例子

大家帮我看看这个jig的例子
www.dimcax.com
大家帮我看看这个jig的例子
using system; using system.collections.generic; using system.text; using autodesk.autocad.applicationservices; using autodesk.autocad.databaseservices; using autodesk.autocad.graphicsinterface; using autodesk.autocad.editorinput; using autodesk.autocad.runtime; using autodesk.autocad.colors; using autodesk.autocad.geometry; using app = autodesk.autocad.applicationservices.application; namespace green { public class grasshatch { private matrix3d ucsmatrix; private point3d m_basepoint; private point3d m_destinationpoint; private matrix3d transmat; [commandmethod("drag",)] public void copyalongcurve() { database db = hostapplicationservices.workingdatabase; editor ed = application.documentmanager.mdiactivedocument.editor; try { promptselectionoptions ssoptions = new promptselectionoptions(); ssoptions.messageforadding = "\n选择拖拽的实体 "; ssoptions.messageforremoval = "\n移除实体 "; ssoptions.allowduplicates = true; promptselectionresult ssresult = ed.getselection(ssoptions); if (ssresult.status != promptstatus.ok) return; if (ssresult.value.count == 0) return; ucsmatrix = ed.currentusercoordinatesystem; promptpointresult pointresult = ed.getpoint("\n选取基点: "); if (pointresult.status != promptstatus.ok) return; ucsmatrix = ed.currentusercoordinatesystem; m_basepoint = pointresult.value.transformby(ucsmatrix); do { using (transaction myt = db.transactionmanager.starttransaction()) { dragcallback dragcallbackdelegate = this.followcursor; //start the drag operation promptdragoptions dragoptions = new promptdragoptions(ssresult.value, "\n插入实体:", dragcallbackdelegate); promptpointresult destinationpointresult = ed.drag(dragoptions); if (destinationpointresult.status != promptstatus.ok) return; m_destinationpoint = destinationpointresult.value.transformby(ucsmatrix); //m_destinationpoint = destinationpointresult.value; //point3d tmpdestinationpoint = basecurve.getclosestpointto(m_destinationpoint, false); myt.commit(); } //transform the ss to the new location //this.transformselectionset2(ssresult.value, transmat); this.transformselectionset(ssresult.value, transmat); } while (true); } finally { //myt.dispose(); } } //dragcallback delegate public samplerstatus followcursor(point3d currentpoint, ref matrix3d transmat) { transmat = matrix3d.displacement(m_basepoint.getvectorto(currentpoint)); return samplerstatus.ok; } private void transformselectionset(selectionset ss, matrix3d transmat) { if (ss.count == 0) { return; } database targetdatabase = ss[0].objectid.database; using (transaction trans = targetdatabase.transactionmanager.starttransaction()) { blocktablerecord currentspace = (blocktablerecord)trans.getobject(targetdatabase.currentspaceid, openmode.forwrite); foreach (selectedobject selectedobj in ss) { entity selectedentity = (entity)trans.getobject(selectedobj.objectid, openmode.forread); entity transformedentity = selectedentity.gettransformedcopy(transmat); currentspace.appendentity(transformedentity); trans.addnewlycreateddbobject(transformedentity, true); } trans.commit(); } } private void transformselectionset2(selectionset ss, matrix3d transmatrix) { if (ss.count == 0) return; database targetdatabase = ss[0].objectid.database; using (transaction trans = targetdatabase.transactionmanager.starttransaction()) { objectidcollection entitycollection = new objectidcollection(ss.getobjectids()); idmapping idmap = new idmapping(); targetdatabase.deepcloneobjects(entitycollection, targetdatabase.currentspaceid, idmap, false); foreach (idpair pair in idmap) { entity clonedentity = (entity)trans.getobject(pair.value, openmode.forwrite); clonedentity.transformby(transmatrix); } trans.commit(); } } } }
这是我做的一个jig的例子,能拖动实体在屏幕上移动,但不能把实体添加到模型空间去,请问问题出在哪?
总能把手机放到我自己找不到的地方...
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



所有的时间均为北京时间。 现在的时间是 03:56 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多