欢迎加我的QQ群:193522571,一起来讨论、交流!

ARX中实现实体的偏移

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;
}
}

posted @ 2014-10-07 11:18  swtool  阅读(884)  评论(0编辑  收藏  举报
欢迎加我的QQ群:193522571,一起来讨论、交流!