![]() |
【转帖】尝试做jig时出现,遇到尝试读取或写入受保护的内存的错误
尝试做jig时出现,遇到尝试读取或写入受保护的内存的错误
尝试做jig时出现,遇到尝试读取或写入受保护的内存的错误 { database db = hostapplicationservices.workingdatabase; editor ed = autodesk.autocad.applicationservices.application.documentmanager.mdiactivedocument.editor; private point3d ptmirrorlinestart, ptmirrorlineend, curpt; private entity[] entcopy; objectid[] ids; public void hymirror() { try { document doc = application.documentmanager.mdiactivedocument; documentlock doclock = doc.lockdocument(); promptselectionoptions optmirrorentity = new promptselectionoptions(); optmirrorentity.messageforadding = "请选择要镜像的对象"; promptselectionresult reskey = ed.getselection(optmirrorentity); if (reskey.status == promptstatus.ok) { selectionset ssetmirrorentity = reskey.value; ids = ssetmirrorentity.getobjectids(); entcopy = new entity[ids.length - 1]; entity[] oldent = new entity[ids.length - 1]; using (transaction trans = db.transactionmanager.starttransaction()) { for (int i = 0; i < ids.length - 1; i++) { oldent = (entity)trans.getobject(ids, openmode.forwrite); entcopy = (entity)oldent.clone(); } promptpointoptions optpointstrat = new promptpointoptions("请选择镜像线的起点"); promptpointresult respoint = ed.getpoint(optpointstrat); if (respoint.status != promptstatus.cancel) { if (respoint.status == promptstatus.none) ptmirrorlinestart = new point3d(0, 0, 0); else ptmirrorlinestart = respoint.value; } ptmirrorlineend = ptmirrorlinestart; curpt = ptmirrorlineend; promptresult jigres = ed.drag(this); if (jigres.status == promptstatus.ok) { trans.commit(); } doclock.dispose(); } } } catch (system.exception e) { application.showalertdialog(e.tostring()); } } protected override bool worlddraw(autodesk.autocad.graphicsinterface.worlddraw draw) { for (int i = 0; i < ids.length - 1; i++) { draw.geometry.draw(entcopy); } return true; } protected override samplerstatus sampler(jigprompts prompts) { jigpromptoptions optjig = new jigpromptoptions(); optjig.message = "请选择镜像线的终点"; optjig.cursor = cursortype.rubberband; optjig.basepoint = ptmirrorlinestart; optjig.usebasepoint = true; promptpointresult resjig = prompts.acquirepoint(optjig); ptmirrorlineend = resjig.value; if (curpt != ptmirrorlineend) { for (int i = 0; i < ids.length; i++) { dna.tools.mirror(entcopy, ptmirrorlinestart, ptmirrorlineend, false); } curpt = ptmirrorlineend; return samplerstatus.ok; } else { return samplerstatus.nochange; } } } 错误报在promptresult jigres = ed.drag(this);这一行,望大虾们看看。 |
所有的时间均为北京时间。 现在的时间是 10:27 AM. |