getoffsetcurve与OFFSET命令的区别?
<p>请看附件图中的三个二维多段线实体,本人在使用下代码得到它们的偏移实体时:</p><p>AcDb2dPolyline* ppline = AcDb2dPolyline::cast(pEntity);<br/>AcDbVoidPtrArray curves;<br/>Acad::ErrorStatus eoc = ppline->getOffsetCurves(0.2, curves);<br/>if (eoc == Acad::eOk) { </p><p>int count = curves.length();//<br/>..........<br/>}<br/>得到的状态值 eoc = eOk, 可是曲线的数量 count = 0.没有得到任何偏移实体<br/>可是我在用 OFFSET 命令时却能得到相应的曲线,不知道是什么原因,请高手给以指教。</p> <p>这是我写的,希望对你有所帮助:(宽度你可以在该的更合理一点,我没进行宽度的设置)</p><p></p><p>// ObjectARX defined commands, created by , , </p><p>#include "StdAfx.h"<br/>#include "StdArx.h"<br/>#include "geassign.h"</p><p><br/>bool addToModelSpace(AcDbObjectId& objId, AcDbEntity* pEnt)<br/>{<br/> AcDbBlockTable* pBlk;<br/> acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlk, AcDb::kForRead);<br/> AcDbBlockTableRecord* pBlkRed;<br/> pBlk->getAt(ACDB_MODEL_SPACE, pBlkRed, AcDb::kForWrite);<br/> pBlk->close();<br/> pBlkRed->appendAcDbEntity(objId, pEnt);<br/> pBlkRed->close();<br/> pEnt->close();<br/> acutPrintf(_T("操作成功!"));<br/> return true;<br/>}</p><p>//-----------------------------------------------------------------------------<br/>// This is command 'GETOFFSETCURVE, by , , <br/>void zzxgetoffsetcurve()<br/>{<br/>#ifdef OARXWIZDEBUG<br/> acutPrintf ("\nOARXWIZDEBUG - zzxgetoffsetcurve() called.");<br/>#endif // OARXWIZDEBUG</p><p> // TODO: Implement the command<br/> ads_name eName;<br/> AcGePoint3d ptSel;<br/> if (acedEntSel(_T("\n请选择要偏移的对象:"), eName, asDblArray(ptSel)) != RTNORM)<br/> {<br/> acutPrintf(_T("\n选择有误!"));<br/> return;<br/> }</p><p> AcDbObjectId objId;<br/> AcDbCurve* pEnt;<br/> acdbGetObjectId(objId, eName);<br/> if (acdbOpenObject(pEnt, objId, AcDb::kForWrite) != Acad::eOk)<br/> {<br/> acutPrintf(_T("\n打开实体失败!"));<br/> return;<br/> }</p><p> if (!pEnt->isKindOf(AcDbCurve::desc()))<br/> {<br/> acutPrintf(_T("\n该实体无法进行偏移!"));<br/> return;<br/> }<br/> <br/> AcDbVoidPtrArray ptrArr;<br/> pEnt->getOffsetCurves(0.5, ptrArr);<br/> pEnt->close();<br/> <br/> AcDbObjectId newobjId;<br/> addToModelSpace(newobjId, (AcDbEntity*)ptrArr); </p><p>}</p>谢谢,知道原因了,结帖:)
本帖最后由 作者 于 2008-7-25 16:06:34 编辑如题。
页:
[1]