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