|
[code]AcDbObjectPointer
class AcDbObjectPointer;
typedef AcDbObjectPointer<AcDbDictionary> AcDbDictionaryPointer;
typedef AcDbObjectPointer<AcDbEntity> AcDbEntityPointer;
AcDbSymbolTablePointer
typedef AcDbSymbolTablePointer<AcDbBlockTable> AcDbBlockTablePointer;
typedef AcDbSymbolTablePointer<AcDbDimStyleTable> AcDbDimStyleTablePointer;
typedef AcDbSymbolTablePointer<AcDbLayerTable> AcDbLayerTablePointer;
typedef AcDbSymbolTablePointer<AcDbLinetypeTable> AcDbLinetypeTablePointer;
typedef AcDbSymbolTablePointer<AcDbRegAppTable> AcDbRegAppTablePointer;
typedef AcDbSymbolTablePointer<AcDbTextStyleTable> AcDbTextStyleTablePointer;
typedef AcDbSymbolTablePointer<AcDbUCSTable> AcDbUCSTablePointer;
typedef AcDbSymbolTablePointer<AcDbViewTable> AcDbViewTablePointer;
typedef AcDbSymbolTablePointer<AcDbViewportTable> AcDbViewportTablePointer;
AcDbSymbolTableRecordPointer
typedef AcDbSymbolTableRecordPointer<AcDbBlockTableRecord>
AcDbBlockTableRecordPointer;
typedef AcDbSymbolTableRecordPointer<AcDbDimStyleTableRecord>
AcDbDimStyleTableRecordPointer;
typedef AcDbSymbolTableRecordPointer<AcDbLayerTableRecord>
AcDbLayerTableRecordPointer;
typedef AcDbSymbolTableRecordPointer<AcDbLinetypeTableRecord>
AcDbLinetypeTableRecordPointer;
typedef AcDbSymbolTableRecordPointer<AcDbRegAppTableRecord>
AcDbRegAppTableRecordPointer;
typedef AcDbSymbolTableRecordPointer<AcDbTextStyleTableRecord>
AcDbTextStyleTableRecordPointer;
typedef AcDbSymbolTableRecordPointer<AcDbUCSTableRecord>
AcDbUCSTableRecordPointer;
typedef AcDbSymbolTableRecordPointer<AcDbViewTableRecord>
AcDbViewTableRecordPointer;
typedef AcDbSymbolTableRecordPointer<AcDbViewportTableRecord>
AcDbViewportTableRecordPointer;
例子
AcDbBlockTableRecordPointer curSpace(
curDoc()->database()->currentSpaceId(),
AcDb::kForWrite);
if (curSpace.openStatus() == Acad::eOk)
{
...
}
AcDbObjectPointer<AcDbLine> line;
line.create();
line->setStartPoint(AcGePoint3d(0, 0, 0));
line->setEndPoint(AcGePoint3d(10, 10, 0));
AcDbBlockTableRecordPointer curSpace(
acDocManager->curDocument()->database()->currentSpaceId(),
AcDb::kForWrite);
if (curSpace.openStatus() == Acad::eOk)
{
curSpace->appendAcDbEntity(line);
}
//这个例子在AcDbEntity添加扩展字典数据,使用AcDbEntityPointer 、AcDbDictionaryPointer 、AcDbObjectPointer<AcDbXrecord> 这些类实例销毁时,自动关闭Arx实体/对象,且不用担心中间代码抛出异常。
bool SetEntityDictFromRbChain(AcDbObjectId entId,ACHAR *strDictName,resbuf* pRbValue)
{
AcDbEntityPointer pObj(entId,AcDb::kForWrite);
if (pObj.openStatus()!=Acad::eOk ) return false;
AcDbObjectId extDictId = pObj->extensionDictionary();
if (extDictId == AcDbObjectId::kNull)
{
Acad::ErrorStatus es = pObj->createExtensionDictionary();
if (es != Acad::eOk) return false;
if ((extDictId = pObj->extensionDictionary()) == AcDbObjectId::kNull)
return false;
}
AcDbDictionaryPointer pDict(extDictId,AcDb::kForRead);
if(pDict.openStatus() != Acad::eOk)
return false;
AcDbObjectId xRecId;
if(pDict->getAt(strDictName,xRecId) != Acad::eOk)
{
AcDbXrecord* pXrec = new AcDbXrecord();
//pXrec 可以使用scoped_ptr
pDict->upgradeOpen();
if(pDict->setAt(strDictName,pXrec,xRecId) != Acad::eOk)
{
delete pXrec;
return false;
}
pXrec->close();
}
AcDbObjectPointer<AcDbXrecord> pXrcord(xRecId,AcDb::kForWrite);
if(pXrcord.openStatus() != Acad::eOk) return false;
if(pXrcord->setFromRbChain(*pRbValue) != Acad::eOk) return false;
acutRelRb(pRbValue);
return true;
}[/code] |
|