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

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   ObjectARX(C++) (http://www.dimcax.com/hust/forumdisplay.php?f=34)
-   -   【转帖】[求助]为什么夹点拖动会出现错误中断,怎么解决 (http://www.dimcax.com/hust/showthread.php?t=6705)

yang686526 2009-04-16 02:46 PM

【转帖】[求助]为什么夹点拖动会出现错误中断,怎么解决
 
[求助]为什么夹点拖动会出现错误中断,怎么解决
[求助]为什么夹点拖动会出现错误中断,怎么解决
为什么夹点拖动会出现错误中断,怎样解决?谢谢
我用objectarx做了一个剖视符号的自定义实体,可是有时候拖动夹点会弹出下面的对话框
致命错误:unhandled access violation reading 0x12c0000 exception at 63acda70h
请大家帮帮我,万分感激
自定义实体的virtual函数都重载了吗?比如getgrippoint之类的,movegrippoint。光贴个地址没用,版本不同,异常的地址是不同的,要分析。贴点代码出来。
请问怎么样读取多点,谢谢
都重载了,代码如下,调试发现问题出现在倒数第二个if,谢了
acad::errorstatus tyicdbsectviewsym::movegrippointsat (const acdbintarray &indices, const acgevector3d &offset)
{
assertwriteenabled () ;
//----- this method is never called unless you return enotimplemented
//----- from the new movegrippointsat() method below (which is the default implementation)

for(int i=0; i<indices.length(); ++i)
{
int index = indices.at(i);
if (index == 0)
{
view_name_pnt += offset;
break;
}
if (index == 1)
{
acgepoint3d tempnt = ori_dir_pnt + offset;
acgevector3d ver = ori_dir_pnt - m_pnts[0];
acgevector3d ofs_ver = tempnt - m_pnts[0];
if (ver.angleto(ofs_ver) > 0.5 * pi)
{
acgevector3d tempvec = m_pnts[0] - ori_dir_pnt;
ori_dir_pnt = m_pnts[0] + tempvec;
}
break;
}
if (index == 2)
{
acgepoint3d tempnt = end_dir_pnt + offset;
acgevector3d ver = end_dir_pnt - m_pnts[m_pnts_num - 1];
acgevector3d ofs_ver = tempnt - m_pnts[m_pnts_num - 1];
if (ver.angleto(ofs_ver) > 0.5 * pi)
{
acgevector3d tempvec = m_pnts[m_pnts_num - 1] - end_dir_pnt;
end_dir_pnt = m_pnts[m_pnts_num - 1] + tempvec;
}
break;
}
if ((2 < index) && (index < m_pnts_num + 3))
{
m_pnts[index - 3] += offset;
loca_pnts[index -3] += offset;
if (index == 3 || index == 4 || index == m_pnts_num + 1 || index == m_pnts_num +2)
{
acgevector3d odir_vec(m_pnts[1] - m_pnts[0]);
acgevector3d oarr_vec(ori_dir_pnt - m_pnts[0]);
if (!oarr_vec.isperpendicularto(odir_vec) || (oarr_vec.length() != linelength))
{
acgeplane oplane(m_pnts[0], odir_vec);
acgepoint3d otempnt(ori_dir_pnt.orthoproject(oplane));
acgevector3d otem_vec = otempnt - m_pnts[0];
ori_dir_pnt = m_pnts[0] + linelength * otem_vec.normalize();
}
acgevector3d edir_vec(m_pnts[m_pnts_num - 2] - m_pnts[m_pnts_num -1]);
acgevector3d earr_vec(end_dir_pnt - m_pnts[m_pnts_num -1]);
if (!earr_vec.isperpendicularto(edir_vec) || (earr_vec.length() != linelength))
{
acgeplane eplane(m_pnts[m_pnts_num -1], edir_vec);
acgepoint3d etempnt(end_dir_pnt.orthoproject(eplane));
acgevector3d etem_vec = etempnt - m_pnts[m_pnts_num -1];
ori_dir_pnt = m_pnts[m_pnts_num -1] + linelength * etem_vec.normalize();
}
}
break;
}
if ((m_pnts_num + 2 < index) && (index < 2 * m_pnts_num + 3))
{
loca_pnts[index - m_pnts_num - 3] += offset;
break;
}
}

return acad::eok;
//return (acdbentity::movegrippointsat (indices, offset)) ;
}
我浏览了一下你代码,我没法调,所以只能给你几点建议。
1.避免数组访问越界。
2.用acgevector3d时注意,是不是0向量。因为move这函数会被不断调用,对调试带来难度。再就是,你这类的基类是撒,根据不同要求,有些情况是需要调用基类的move的。要看你要做什么。
3.确定crash是确定发生在你的代码。而不是由你产生错误,导致cad其他地方crash,后一种较难调。如果发生在你的code。那就把倒数第二个if全comment。运行,如果不crash,可以确定是在这里面问题,慢慢减小范围来查。comment最多造成功能不正确。若可避免crash,问题就很清楚,重新审视这段代码吧


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