![]() |
【转帖】有关拖动的问题 - 精华帖集合
有关拖动的问题 - 精华帖集合
www.dimcax.com 有关拖动的问题 重载sampler函数时,获取角度应该怎么做?调用acquireangle方法好像得到的是距离而不是角度 acquireangle方法是在什么地方的?我没见过。 c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。 按照arx例子写了一个块的拖动类,有两个动作:移动和旋转 移动取点,旋转取角度 代码中promptpointresult res = prompts.acquirepoint(jigopts);是取点的动作,想改为acquireangle一直没有成功 代码如下: using system; using autodesk.autocad.databaseservices; using autodesk.autocad.geometry; using autodesk.autocad.editorinput; using autodesk.autocad.applicationservices; namespace tlscad { public class blockrefjig:entityjig { point3d mposition; double mangle; int mpromptcounter; public blockrefjig(objectid id):base(new blockreference(new point3d(0,0,0),id)) { mposition=new point3d(0,0,0); mangle=0; } protected override samplerstatus sampler(jigprompts prompts) { jigpromptoptions jigopts = new jigpromptoptions(); if(mpromptcounter == 0) { jigopts.userinputcontrols = (userinputcontrols.accept3dcoordinates | userinputcontrols.nozeroresponseaccepted | userinputcontrols.nonegativeresponseaccepted ); jigopts.message = "\n请输入基点:"; promptpointresult dres = prompts.acquirepoint(jigopts); point3d positiontemp = dres.value; if(positiontemp != mposition) { mposition = positiontemp; } else return samplerstatus.nochange; if(dres.status == promptstatus.cancel) return samplerstatus.cancel; else return samplerstatus.ok; } else if (mpromptcounter == 1) { jigopts.userinputcontrols = (userinputcontrols.accept3dcoordinates | userinputcontrols.nonegativeresponseaccepted); jigopts.basepoint = mposition; jigopts.usebasepoint = true; jigopts.message = "\n请输入旋转角度:"; double angletemp = -1; promptpointresult res = prompts.acquirepoint(jigopts); point3d anglepnt = res.value; angletemp = anglepnt.getvectorto(mposition).angleonplane( new plane( application.documentmanager.mdiactivedocument.database.ucsorg, application.documentmanager.mdiactivedocument.database.ucsxdir, application.documentmanager.mdiactivedocument.database.ucsydir )); if (angletemp != mangle) mangle = angletemp; else return samplerstatus.nochange; if(res.status == promptstatus.cancel) return samplerstatus.cancel; else return samplerstatus.ok; } else { return samplerstatus.nochange; } } protected override bool update() { try { ((blockreference)entity).position=mposition; ((blockreference)entity).rotation =mangle; } catch(system.exception) { return false; } return true; } public void setpromptcounter(int i) { mpromptcounter = i; } public entity getentity() { return entity; } } } 复制代码 看着有点儿晕哟,先学习学习:) 刚刚试用了2007,拖动的bug已经搞定:) using system; using autodesk.autocad.databaseservices; using autodesk.autocad.geometry; using autodesk.autocad.editorinput; using autodesk.autocad.applicationservices; namespace tlscad { public class blockrefjig:entityjig { point3d mposition; double mangle; int mpromptcounter; public blockrefjig(objectid id):base(new blockreference(new point3d(0,0,0),id)) { mposition=new point3d(0,0,0); mangle=0; } protected override samplerstatus sampler(jigprompts prompts) { if(mpromptcounter == 0) { jigpromptpointoptions jigopts = new jigpromptpointoptions(); jigopts.userinputcontrols = (userinputcontrols.accept3dcoordinates | userinputcontrols.nozeroresponseaccepted | userinputcontrols.nonegativeresponseaccepted ); jigopts.message = "\n请输入基点:"; promptpointresult res = prompts.acquirepoint(jigopts); point3d positiontemp = res.value; if(positiontemp != mposition) { mposition = positiontemp; } else return samplerstatus.nochange; if(res.status == promptstatus.cancel) return samplerstatus.cancel; else return samplerstatus.ok; } else if (mpromptcounter == 1) { jigpromptangleoptions jigopts = new jigpromptangleoptions(); jigopts.userinputcontrols = (userinputcontrols.accept3dcoordinates | userinputcontrols.nonegativeresponseaccepted); jigopts.basepoint = mposition; jigopts.usebasepoint = true; jigopts.message = "\n请输入旋转角度:"; promptdoubleresult res = prompts.acquireangle(jigopts); double angletemp = res.value; if (angletemp != mangle) mangle = angletemp; else return samplerstatus.nochange; if (res.status == promptstatus.cancel) return samplerstatus.cancel; else return samplerstatus.ok; } else { return samplerstatus.nochange; } } protected override bool update() { try { ((blockreference)entity).position=mposition; ((blockreference)entity).rotation =mangle; } catch(system.exception) { return false; } return true; } public void setpromptcounter(int i) { mpromptcounter = i; } public entity getentity() { return entity; } } } 复制代码 嗯 [ ] 关于拖动 继承 inherits entityjig 可以实现拖动, 继承 inherits drawjig 也可以实现。 老兄,如何调用此类 |
所有的时间均为北京时间。 现在的时间是 12:29 PM. |