查看单个帖子
旧 2009-04-21, 11:52 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】尝试做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);这一行,望大虾们看看。
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)