sky_sailor 发表于 2008-7-25 11:10:00

getoffsetcurve与OFFSET命令的区别?

<p>请看附件图中的三个二维多段线实体,本人在使用下代码得到它们的偏移实体时:</p><p>AcDb2dPolyline* ppline = AcDb2dPolyline::cast(pEntity);<br/>AcDbVoidPtrArray curves;<br/>Acad::ErrorStatus eoc = ppline-&gt;getOffsetCurves(0.2, curves);<br/>if (eoc == Acad::eOk) { </p><p>int count = curves.length();//<br/>..........<br/>}<br/>得到的状态值&nbsp;eoc = eOk, 可是曲线的数量 count = 0.没有得到任何偏移实体<br/>可是我在用 OFFSET&nbsp;命令时却能得到相应的曲线,不知道是什么原因,请高手给以指教。</p>

zzxxing 发表于 2008-7-25 15:53:00

<p>这是我写的,希望对你有所帮助:(宽度你可以在该的更合理一点,我没进行宽度的设置)</p><p></p><p>// ObjectARX defined commands, created by&nbsp; , , </p><p>#include "StdAfx.h"<br/>#include "StdArx.h"<br/>#include "geassign.h"</p><p><br/>bool addToModelSpace(AcDbObjectId&amp; objId, AcDbEntity* pEnt)<br/>{<br/>&nbsp;AcDbBlockTable* pBlk;<br/>&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()-&gt;getBlockTable(pBlk, AcDb::kForRead);<br/>&nbsp;AcDbBlockTableRecord* pBlkRed;<br/>&nbsp;pBlk-&gt;getAt(ACDB_MODEL_SPACE, pBlkRed, AcDb::kForWrite);<br/>&nbsp;pBlk-&gt;close();<br/>&nbsp;pBlkRed-&gt;appendAcDbEntity(objId, pEnt);<br/>&nbsp;pBlkRed-&gt;close();<br/>&nbsp;pEnt-&gt;close();<br/>&nbsp;acutPrintf(_T("操作成功!"));<br/>&nbsp;return true;<br/>}</p><p>//-----------------------------------------------------------------------------<br/>// This is command 'GETOFFSETCURVE, by&nbsp; , , <br/>void zzxgetoffsetcurve()<br/>{<br/>#ifdef OARXWIZDEBUG<br/>&nbsp;acutPrintf ("\nOARXWIZDEBUG - zzxgetoffsetcurve() called.");<br/>#endif // OARXWIZDEBUG</p><p>&nbsp;// TODO: Implement the command<br/>&nbsp;ads_name eName;<br/>&nbsp;AcGePoint3d ptSel;<br/>&nbsp;if (acedEntSel(_T("\n请选择要偏移的对象:"), eName, asDblArray(ptSel)) != RTNORM)<br/>&nbsp;{<br/>&nbsp;&nbsp;acutPrintf(_T("\n选择有误!"));<br/>&nbsp;&nbsp;return;<br/>&nbsp;}</p><p>&nbsp;AcDbObjectId objId;<br/>&nbsp;AcDbCurve* pEnt;<br/>&nbsp;acdbGetObjectId(objId, eName);<br/>&nbsp;if (acdbOpenObject(pEnt, objId, AcDb::kForWrite) != Acad::eOk)<br/>&nbsp;{<br/>&nbsp;&nbsp;acutPrintf(_T("\n打开实体失败!"));<br/>&nbsp;&nbsp;return;<br/>&nbsp;}</p><p>&nbsp;if (!pEnt-&gt;isKindOf(AcDbCurve::desc()))<br/>&nbsp;{<br/>&nbsp;&nbsp;acutPrintf(_T("\n该实体无法进行偏移!"));<br/>&nbsp;&nbsp;return;<br/>&nbsp;}<br/>&nbsp;<br/>&nbsp;AcDbVoidPtrArray ptrArr;<br/>&nbsp;pEnt-&gt;getOffsetCurves(0.5, ptrArr);<br/>&nbsp;pEnt-&gt;close();<br/>&nbsp;<br/>&nbsp;AcDbObjectId newobjId;<br/>&nbsp;addToModelSpace(newobjId, (AcDbEntity*)ptrArr);&nbsp;</p><p>}</p>

sky_sailor 发表于 2008-7-25 16:02:00

谢谢,知道原因了,结帖:)

本帖最后由 作者 于 2008-7-25 16:06:34 编辑

如题。
页: [1]
查看完整版本: getoffsetcurve与OFFSET命令的区别?