|
[code]将当前图形中的动态块输出为创作元素[/code]
可以将图形中的动态块作为创作元素屏蔽到新图形中。这有助于存档动态块,并在需要时重用它们。可以插入新图形以将动态块放入任何其他图形中。在 AutoCAD UI 中,通过使用 WBLOCK 命令并从当前图形的可用块列表中选择动态块,可以创建创作元素。也可以使用代码来完成相同的操作,如以下代码片段所示:
[code] // Wblock a dynamic block as an AuthoringElement
Acad::ErrorStatus es;
AcApDocument *pActiveDoc
= acDocManager->mdiActiveDocument();
AcDbDatabase *pCurDb = pActiveDoc->database();
AcDbBlockTable* pCurentDwgBlockTable;
es = pCurDb->getBlockTable(
pCurentDwgBlockTable, kForRead);
if ( es == eOk)
{
AcDbBlockTableRecord* pRecord;
// Assuming "Test" dynamic block
// being present in the current drawing
es = pCurentDwgBlockTable->getAt(
ACRX_T("Test" ),
pRecord,
kForRead, false );
if (es != eOk)
{
pCurentDwgBlockTable->close();
return ;
}
AcDbObjectId btrId = pRecord->objectId();
pRecord->close();
pCurentDwgBlockTable->close();
// Create the destination database
AcDbDatabase *pNewDb = NULL;
es = pCurDb->wblock(pNewDb, btrId);
if (es == Acad::eOk)
{
es = pNewDb->saveAs(
_T("D://Temp//TestBlock.dwg" ));
delete pNewDb;
}
}[/code] |
|