static AcDbObjectId OffsetEnty(const ACHAR* BlkName,AcDbObjectId entId,double OfsValue,AcDbDatabase *pDb=CrtEntity:: pPurDb);
//!(多段线特别处理)
AcDbObjectId EditEntity::OffsetEnty(const ACHAR* BlkName,AcDbObjectId entId,double OfsValue,AcDbDatabase *pDb)
{
AcDbEntity *pEnt;
AcDbCurve *pCurv;
AcDbVoidPtrArray offCurvs;
AcDbBlockTable *pBlkTable;
AcDbBlockTableRecord *pBlkTableRecord;
ErrorStatus es;
/*Acad::ErrorStatus es;*/
AcDbObjectId objctid;
es=acdbOpenObject(pEnt, entId, AcDb::kForRead);
if((pCurv = AcDbCurve::cast(pEnt)) == NULL){
pEnt->close();
return NULL;
}
es=pCurv->getOffsetCurves(OfsValue, offCurvs);
if(es!= Acad::eOk){
pEnt->close();
/*acedAlert("设置偏移失败!");*/
return AcDbObjectId::kNull;
}
pEnt->close();
if(!offCurvs.isEmpty()){
pDb->getBlockTable(pBlkTable, AcDb::kForRead);
pBlkTable->getAt(BlkName, pBlkTableRecord, AcDb::kForWrite);
pBlkTable->close();
for(int i = 0; i < offCurvs.length(); i++){
pEnt = (AcDbEntity*)offCurvs.at(i);
pBlkTableRecord->appendAcDbEntity(objctid, pEnt);
}
pEnt->close();
pBlkTableRecord->close();
return objctid;
}
else{
return AcDbObjectId::kNull;
}
}
原文地址:http://www.cnblogs.com/swtool/p/4009112.html