紧急求助,有关AcEdJig 非常奇怪的问题
本帖最后由 作者 于 2007-4-27 0:31:35 编辑 <br /><br /> <p>我用AcEdJig产生几个命令Move/Copy/Mirror/Rotate 来操作我自己定义的 entity. 这些命令在AutoCAD2002/2004运行地很好,但当我升级到AutoCAD2007后,这些命令总是在拖动鼠标时死掉, 那位知道AcEdJig用在AutoCAD2007时与AutoCAD2002/2004版本有何不同. 需要注意些什么.是否有其他途径来实现Move/Copy/Mirror/Rotate命令.</p><p>我定义了以下entity 实现选择物体的Matrix转换和worldDraw. </p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><font face="Times New Roman" size="3">class TransformedObjects : public AcDbEntity</font></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><font face="Times New Roman" size="3">{ .............</font></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><font face="Times New Roman" size="3"> public:</font></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><font size="3"><font face="Times New Roman"> virtual void viewportDraw(AcGiViewportDraw* pVpDraw);</font></font></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><font size="3"><font face="Times New Roman"> virtual Adesk::Boolean worldDraw(AcGiWorldDraw* mode);</font></font></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><font face="Times New Roman" size="3"> ........</font><font face="Times New Roman" size="3"> <p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> private:</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> AcDbObjectIdArray mObjectIds; //objects to be drawn</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><span style="mso-tab-count: 1;"> AcGeMatrix3d mTransform; //Matrix定义</span></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">};</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">我定义Move如下:</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">class ObjectJig : public AcEdJig</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">{</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">public:</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><span style="mso-tab-count: 1;"> ObjectJig();</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> ~ObjectJig();</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> virtual AcDbEntity *entity() const;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> virtual DragStatus sampler();</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> virtual Adesk::Boolean update();</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> virtual DragStatus Run(CString Prompt);</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> void setTransform(AcGeMatrix3d trans);</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> void addObject(AcDbObjectId id);</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> void addObjects(AcDbObjectIdArray &ids);</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> void applyTransform(); //Matrix操作</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">private:</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> TransformedObjects mTransObject;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> AcGeMatrix3d mTransform;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">}</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">class MoveJig : public ObjectJig</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">{</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">public:</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> virtual DragStatus sampler();</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> virtual DragStatus Run(CString Prompt);</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> void setRefPoint(AcGePoint3d pt) {mRefPoint = pt;}</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">private:</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> AcGePoint3d mRefPoint;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> AcGePoint3d mPoint;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">};</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">程序在运行Move时在virtual DragStatus sampler();内部死掉,virtual DragStatus sampler()定义如下</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">AcEdJig::DragStatus MoveJig::sampler()</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">{</p><p></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> AcEdJig::DragStatus ds;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> AcGePoint3d Pt;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> setUserInputControls(AcEdJig::kAccept3dCoordinates);</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> ds = acquirePoint(Pt, mRefPoint);</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> if(ds == AcEdJig::kCancel)</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> return ds;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> if(mPoint.isEqualTo(Pt))</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> return AcEdJig::kNoChange;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> mPoint = Pt;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> setTransform(AcGeMatrix3d::translation(mPoint - mRefPoint));</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> return ds;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">}</p></span></font></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> private:</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> AcDbObjectIdArray mObjectIds; //objects to be drawn</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><span style="mso-tab-count: 1;"> AcGeMatrix3d mTransform; //Matrix定义</span></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">};</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">我定义Move如下:</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">class ObjectJig : public AcEdJig</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">{</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">public:</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><span style="mso-tab-count: 1;"> ObjectJig();</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> ~ObjectJig();</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> virtual AcDbEntity *entity() const;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> virtual DragStatus sampler();</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> virtual Adesk::Boolean update();</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> virtual DragStatus Run(CString Prompt);</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> void setTransform(AcGeMatrix3d trans);</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> void addObject(AcDbObjectId id);</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> void addObjects(AcDbObjectIdArray &ids);</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> void applyTransform(); //Matrix操作</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">private:</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> TransformedObjects mTransObject;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> AcGeMatrix3d mTransform;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">}</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">class MoveJig : public ObjectJig</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">{</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">public:</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> virtual DragStatus sampler();</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> virtual DragStatus Run(CString Prompt);</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> void setRefPoint(AcGePoint3d pt) {mRefPoint = pt;}</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">private:</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> AcGePoint3d mRefPoint;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> AcGePoint3d mPoint;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">};</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">程序在运行Move时在virtual DragStatus sampler();内部死掉,virtual DragStatus sampler()定义如下</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">AcEdJig::DragStatus MoveJig::sampler()</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">{</p><p></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> AcEdJig::DragStatus ds;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> AcGePoint3d Pt;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> setUserInputControls(AcEdJig::kAccept3dCoordinates);</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> ds = acquirePoint(Pt, mRefPoint);</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> if(ds == AcEdJig::kCancel)</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> return ds;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> if(mPoint.isEqualTo(Pt))</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> return AcEdJig::kNoChange;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> mPoint = Pt;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> setTransform(AcGeMatrix3d::translation(mPoint - mRefPoint));</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> return ds;</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">}</p></span><p></p><p></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"> 具体实施Move的函数如下</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><font face="Times New Roman" size="3">AcEdJig::DragStatus MoveJig::Run(CString Prompt)</font></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">{</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><font face="Times New Roman" size="3"> AcEdJig::DragStatus status;</font></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><font size="3"><font face="Times New Roman"> mPoint = mRefPoint;</font></font></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><font size="3"><font face="Times New Roman"> setDispPrompt(Prompt);</font></font></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><font face="Times New Roman" size="3"></font></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><font size="3"><font face="Times New Roman"> status = drag();</font></font></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><font face="Times New Roman" size="3"></font></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><font size="3"><font face="Times New Roman"> if(status == AcEdJig::kNormal)</font></font></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><font size="3"><font face="Times New Roman"> applyTransform();</font></font></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><font face="Times New Roman" size="3"></font></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"><font size="3"><font face="Times New Roman"> return status;</font></font></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">}</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;">望那位高手指点迷津,多谢了</p><p class="MsoNormal" style="MARGIN: 0in 0in 0pt;"></p><p></p>
页:
[1]