[求助]为什么夹点拖动会出现错误中断,怎么解决
<p>为什么夹点拖动会出现错误中断,怎样解决?谢谢</p><p>我用ObjectARX做了一个剖视符号的自定义实体,可是有时候拖动夹点会弹出下面的对话框</p><p>致命错误:Unhandled Access Violation Reading 0x12c0000 Exception at 63acda70h</p><p>请大家帮帮我,万分感激</p> <p>自定义实体的virtual函数都重载了吗?比如getGripPoint之类的,moveGripPoint。光贴个地址没用,版本不同,异常的地址是不同的,要分析。贴点代码出来。</p>请问怎么样读取多点,谢谢
<p>都重载了,代码如下,调试发现问题出现在倒数第二个if,谢了</p><p>Acad::ErrorStatus TyIcDbSectViewSym::moveGripPointsAt (const AcDbIntArray &indices, const AcGeVector3d &offset)<br/>{<br/> assertWriteEnabled () ;<br/> //----- This method is never called unless you return eNotImplemented <br/> //----- from the new moveGripPointsAt() method below (which is the default implementation)<br/> <br/> for(int i=0; i<indices.length(); ++i) <br/> {</p><p> int index = indices.at(i);<br/> if (index == 0)<br/> {<br/> view_name_pnt += offset;<br/> break;<br/> }<br/> if (index == 1)<br/> {<br/> AcGePoint3d tempnt = ori_dir_pnt + offset;<br/> AcGeVector3d ver = ori_dir_pnt - m_pnts;<br/> AcGeVector3d ofs_ver = tempnt - m_pnts;<br/> if (ver.angleTo(ofs_ver) > 0.5 * PI)<br/> {<br/> AcGeVector3d tempvec = m_pnts - ori_dir_pnt;<br/> ori_dir_pnt = m_pnts + tempvec;<br/> }<br/> break;<br/> }<br/> if (index == 2)<br/> {<br/> AcGePoint3d tempnt = end_dir_pnt + offset;<br/> AcGeVector3d ver = end_dir_pnt - m_pnts;<br/> AcGeVector3d ofs_ver = tempnt - m_pnts;<br/> if (ver.angleTo(ofs_ver) > 0.5 * PI)<br/> {<br/> AcGeVector3d tempvec = m_pnts - end_dir_pnt;<br/> end_dir_pnt = m_pnts + tempvec;<br/> }<br/> break;<br/> }<br/> if ((2 < index) && (index < m_pnts_num + 3))<br/> {<br/> m_pnts += offset;<br/> loca_pnts += offset;</p><p> if (index == 3 || index == 4 || index == m_pnts_num + 1 || index == m_pnts_num +2)<br/> {<br/> AcGeVector3d odir_vec(m_pnts - m_pnts);<br/> AcGeVector3d oarr_vec(ori_dir_pnt - m_pnts);<br/> if (!oarr_vec.isPerpendicularTo(odir_vec) || (oarr_vec.length() != LineLength))<br/> {<br/> AcGePlane oplane(m_pnts, odir_vec);<br/> AcGePoint3d otempnt(ori_dir_pnt.orthoProject(oplane));<br/> AcGeVector3d otem_vec = otempnt - m_pnts;<br/> ori_dir_pnt = m_pnts + LineLength * otem_vec.normalize();<br/> }</p><p> AcGeVector3d edir_vec(m_pnts - m_pnts);<br/> AcGeVector3d earr_vec(end_dir_pnt - m_pnts);<br/> if (!earr_vec.isPerpendicularTo(edir_vec) || (earr_vec.length() != LineLength))<br/> {<br/> AcGePlane eplane(m_pnts, edir_vec);<br/> AcGePoint3d etempnt(end_dir_pnt.orthoProject(eplane));<br/> AcGeVector3d etem_vec = etempnt - m_pnts;<br/> ori_dir_pnt = m_pnts + LineLength * etem_vec.normalize();<br/> }<br/> }</p><p> break;<br/> }<br/> if ((m_pnts_num + 2 < index) && (index < 2 * m_pnts_num + 3))<br/> {<br/> loca_pnts += offset;<br/> break;<br/> }</p><p>}<br/> <br/> return Acad::eOk;</p><p> //return (AcDbEntity::moveGripPointsAt (indices, offset)) ;<br/>}</p> <p>我浏览了一下你代码,我没法调,所以只能给你几点建议。</p><p>1.避免数组访问越界。 </p><p>2.用AcGeVector3d时注意,是不是0向量。因为move这函数会被不断调用,对调试带来难度。再就是,你这类的基类是撒,根据不同要求,有些情况是需要调用基类的move的。要看你要做什么。</p><p>3.确定Crash是确定发生在你的代码。而不是由你产生错误,导致CAD其他地方CRASH,后一种较难调。如果发生在你的CODE。那就把倒数第二个IF全comment。运行,如果不crash,可以确定是在这里面问题,慢慢减小范围来查。comment最多造成功能不正确。若可避免crash,问题就很清楚,重新审视这段代码吧</p>
页:
[1]