- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
static AcDbRegion* GetRegion(AcGePoint3d cenPt)
{
AcDbRegion* pRegion = NULL;
AcDbCircle* pCircle = new AcDbCircle(cenPt,AcGeVector3d::kZAxis,10);
AcDbVoidPtrArray curveSegments;curveSegments.append(pCircle);
AcDbVoidPtrArray regions;
Acad::ErrorStatus es = AcDbRegion::createFromCurves(curveSegments,regions);
delete pCircle;pCircle = NULL;
if(Acad::eOk == es && regions.length()>0)
{
AcDbRegion* pTmpRegion = (AcDbRegion*)regions[0];
if(pTmpRegion)
{
pRegion = (AcDbRegion*)pTmpRegion->clone();
}
}
for(int i=0;i<regions.length();++i)
{
delete (AcRxObject*)regions[i];
}
return pRegion;
}
static AcDbObjectId PostToModelSpace(AcDbEntity* pEnt,AcDbDatabase *pDb = acdbCurDwg())
{
Acad::ErrorStatus es;
AcDbObjectId entId = AcDbObjectId::kNull;
AcDbBlockTable * pBlockTable = NULL;
pEnt->setDatabaseDefaults(pDb);
es = pDb->getBlockTable(pBlockTable, AcDb::kForRead);
if (es != Acad::eOk)
{
return entId;
}
AcDbBlockTableRecord *pBlockTableRecord = NULL;
es = pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,AcDb::kForWrite);
pBlockTable->close();
if (es != Acad::eOk)
{
return entId;
}
es = pBlockTableRecord->appendAcDbEntity(entId, pEnt);
pBlockTableRecord->close();
pEnt->close();
return entId;
}
Acad::ErrorStatus es;
AcDbRegion* pRegion1 = GetRegion(AcGePoint3d(0,0,0));
AcDbRegion* pRegion2 = GetRegion(AcGePoint3d(10,0,0));
if(pRegion1 && pRegion2)
{
es = pRegion1->booleanOper(AcDb::kBoolUnite,pRegion2);
if(Acad::eOk == es && pRegion2->isNull())
{
delete pRegion2;pRegion2 = NULL;
}
}
AcDbRegion* pTmp = (AcDbRegion*)pRegion1->clone();
AcDbObjectId id1 = PostToModelSpace(pTmp,acdbCurDwg());
AcDbDatabase* pDb = new AcDbDatabase(true,false);
pRegion1->setDatabaseDefaults(pDb);
AcDbObjectId id2 = PostToModelSpace(pRegion1,pDb);
pDb->saveAs(_T("D:\\Region.dwg"));delete pDb;
return;
id1 is ok.id2 is null;
@tbrammer @daniel_cadext @Alexander.Rivilis
Solved! Go to Solution.
Link copied