zhangyusheng 发表于 2008-3-1 10:59:00

[求助]为什么夹点拖动会出现错误中断,怎么解决

<p>为什么夹点拖动会出现错误中断,怎样解决?谢谢</p><p>我用ObjectARX做了一个剖视符号的自定义实体,可是有时候拖动夹点会弹出下面的对话框</p><p>致命错误:Unhandled Access Violation Reading 0x12c0000 Exception at 63acda70h</p><p>请大家帮帮我,万分感激</p>

bluelightcsy 发表于 2008-3-1 11:33:00

<p>自定义实体的virtual函数都重载了吗?比如getGripPoint之类的,moveGripPoint。光贴个地址没用,版本不同,异常的地址是不同的,要分析。贴点代码出来。</p>

zhangyusheng 发表于 2008-3-1 11:46:00

请问怎么样读取多点,谢谢

<p>都重载了,代码如下,调试发现问题出现在倒数第二个if,谢了</p><p>Acad::ErrorStatus TyIcDbSectViewSym::moveGripPointsAt (const AcDbIntArray &amp;indices, const AcGeVector3d &amp;offset)<br/>{<br/>&nbsp;assertWriteEnabled () ;<br/>&nbsp;//----- This method is never called unless you return eNotImplemented <br/>&nbsp;//----- from the new moveGripPointsAt() method below (which is the default implementation)<br/>&nbsp;<br/>&nbsp;&nbsp;for(int i=0; i&lt;indices.length(); ++i) <br/>&nbsp;&nbsp;{</p><p>&nbsp;&nbsp;int index = indices.at(i);<br/>&nbsp;&nbsp;if (index == 0)<br/>&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;view_name_pnt += offset;<br/>&nbsp;&nbsp;&nbsp;break;<br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;if (index == 1)<br/>&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;AcGePoint3d tempnt = ori_dir_pnt + offset;<br/>&nbsp;&nbsp;&nbsp;AcGeVector3d ver = ori_dir_pnt - m_pnts;<br/>&nbsp;&nbsp;&nbsp;AcGeVector3d ofs_ver = tempnt - m_pnts;<br/>&nbsp;&nbsp;&nbsp;if (ver.angleTo(ofs_ver) &gt; 0.5 * PI)<br/>&nbsp;&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;&nbsp;AcGeVector3d tempvec = m_pnts - ori_dir_pnt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;ori_dir_pnt = m_pnts + tempvec;<br/>&nbsp;&nbsp;&nbsp;}<br/>&nbsp;&nbsp;&nbsp;break;<br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;if (index == 2)<br/>&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;AcGePoint3d tempnt = end_dir_pnt + offset;<br/>&nbsp;&nbsp;&nbsp;AcGeVector3d ver = end_dir_pnt - m_pnts;<br/>&nbsp;&nbsp;&nbsp;AcGeVector3d ofs_ver = tempnt - m_pnts;<br/>&nbsp;&nbsp;&nbsp;if (ver.angleTo(ofs_ver) &gt; 0.5 * PI)<br/>&nbsp;&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;&nbsp;AcGeVector3d tempvec = m_pnts - end_dir_pnt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;end_dir_pnt = m_pnts + tempvec;<br/>&nbsp;&nbsp;&nbsp;}<br/>&nbsp;&nbsp;&nbsp;break;<br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;if ((2 &lt; index) &amp;&amp; (index &lt; m_pnts_num + 3))<br/>&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;m_pnts += offset;<br/>&nbsp;&nbsp;&nbsp;loca_pnts += offset;</p><p>&nbsp;&nbsp;&nbsp;if (index == 3 || index == 4 || index == m_pnts_num + 1 || index == m_pnts_num +2)<br/>&nbsp;&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;&nbsp;AcGeVector3d odir_vec(m_pnts - m_pnts);<br/>&nbsp;&nbsp;&nbsp;&nbsp;AcGeVector3d oarr_vec(ori_dir_pnt - m_pnts);<br/>&nbsp;&nbsp;&nbsp;&nbsp;if (!oarr_vec.isPerpendicularTo(odir_vec) || (oarr_vec.length() != LineLength))<br/>&nbsp;&nbsp;&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AcGePlane oplane(m_pnts, odir_vec);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AcGePoint3d otempnt(ori_dir_pnt.orthoProject(oplane));<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AcGeVector3d otem_vec = otempnt - m_pnts;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ori_dir_pnt = m_pnts + LineLength * otem_vec.normalize();<br/>&nbsp;&nbsp;&nbsp;&nbsp;}</p><p>&nbsp;&nbsp;&nbsp;&nbsp;AcGeVector3d edir_vec(m_pnts - m_pnts);<br/>&nbsp;&nbsp;&nbsp;&nbsp;AcGeVector3d earr_vec(end_dir_pnt - m_pnts);<br/>&nbsp;&nbsp;&nbsp;&nbsp;if (!earr_vec.isPerpendicularTo(edir_vec) || (earr_vec.length() != LineLength))<br/>&nbsp;&nbsp;&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AcGePlane eplane(m_pnts, edir_vec);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AcGePoint3d etempnt(end_dir_pnt.orthoProject(eplane));<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AcGeVector3d etem_vec = etempnt - m_pnts;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ori_dir_pnt = m_pnts + LineLength * etem_vec.normalize();<br/>&nbsp;&nbsp;&nbsp;&nbsp;}<br/>&nbsp;&nbsp;&nbsp;}</p><p>&nbsp;&nbsp;&nbsp;break;<br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;if ((m_pnts_num + 2 &lt; index) &amp;&amp; (index &lt; 2 * m_pnts_num + 3))<br/>&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp;loca_pnts += offset;<br/>&nbsp;&nbsp;&nbsp;break;<br/>&nbsp;&nbsp;}</p><p>}<br/>&nbsp;<br/>&nbsp;return Acad::eOk;</p><p>&nbsp;//return (AcDbEntity::moveGripPointsAt (indices, offset)) ;<br/>}</p>

bluelightcsy 发表于 2008-3-1 12:09:00

<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]
查看完整版本: [求助]为什么夹点拖动会出现错误中断,怎么解决