//
旋转Group
Acad::ErrorStatus rotationGroup( const char * strGroupName,
const AcGePoint3d & ptRotation,
double rotationAngle)
... {
// 得到Group字典
AcGePoint3d pt;
AcDbDictionary *pGroupDict = NULL;
Acad::ErrorStatus es = acdbHostApplicationServices()->workingDatabase()
->getGroupDictionary(pGroupDict, AcDb::kForWrite);
if (es != Acad::eOk)
return es;
// 根据Group名的到Group对象
AcDbObjectId groupId;
AcDbGroup *pGroup;
pt.x = ptRotation.x;
pt.y = ptRotation.y;
pt.z = ptRotation.z;
es = pGroupDict->getAt(strGroupName, pGroup, AcDb::kForWrite);
if (es != Acad::eOk)
...{
pGroupDict->close();
return es;
}
pGroupDict->close();
// 遍历Group对象,对其中每一个实体都进行旋转
AcDbGroupIterator* pIter = pGroup->newIterator();
AcDbEntity* pEnt = NULL;
AcDbObjectId objId;
AcGeMatrix3d mat;
mat.setToRotation(rotationAngle, AcGeVector3d::kZAxis, ptRotation);
for(; !pIter->done(); pIter->next())
...{
es = pIter->getObject(pEnt, AcDb::kForWrite);
if (es != Acad::eOk)
continue;
pEnt->transformBy(mat);
pEnt->close();
}
delete pIter;
pGroup->close();
return Acad::eOk;
}
Acad::ErrorStatus rotationGroup( const char * strGroupName,
const AcGePoint3d & ptRotation,
double rotationAngle)
... {
// 得到Group字典
AcGePoint3d pt;
AcDbDictionary *pGroupDict = NULL;
Acad::ErrorStatus es = acdbHostApplicationServices()->workingDatabase()
->getGroupDictionary(pGroupDict, AcDb::kForWrite);
if (es != Acad::eOk)
return es;
// 根据Group名的到Group对象
AcDbObjectId groupId;
AcDbGroup *pGroup;
pt.x = ptRotation.x;
pt.y = ptRotation.y;
pt.z = ptRotation.z;
es = pGroupDict->getAt(strGroupName, pGroup, AcDb::kForWrite);
if (es != Acad::eOk)
...{
pGroupDict->close();
return es;
}
pGroupDict->close();
// 遍历Group对象,对其中每一个实体都进行旋转
AcDbGroupIterator* pIter = pGroup->newIterator();
AcDbEntity* pEnt = NULL;
AcDbObjectId objId;
AcGeMatrix3d mat;
mat.setToRotation(rotationAngle, AcGeVector3d::kZAxis, ptRotation);
for(; !pIter->done(); pIter->next())
...{
es = pIter->getObject(pEnt, AcDb::kForWrite);
if (es != Acad::eOk)
continue;
pEnt->transformBy(mat);
pEnt->close();
}
delete pIter;
pGroup->close();
return Acad::eOk;
}