如何在Bricscad中制作表格
尽管 Bricscad 不支持表,但 ODA 库支持,因此可以通过 DRX 将表添加到 DWG。 Bricscad将把它画成一个方块。//++-- A sample Command class...Daniel Marcotte
class CommandAddTable : public OdStaticRxObject
{
public:
const OdString localName() const {return globalName();}
const OdString groupName() const {return DD_T("DRXGLOBAL");}
const OdString globalName() const {return DD_T("AddTable");}
void execute(OdEdCommandContext* pCmdCtx)
{
ASSERT(pCmdCtx != NULL);
if(pCmdCtx == NULL)
return;
OdDbCommandContextPtr pDbCmdCtx(pCmdCtx);
OdDbUserIOPtr pDbIO = pDbCmdCtx->dbUserIO();
OdDbDatabasePtr pDb = pDbCmdCtx->database();
if(pDb.isNull())
return;
//++--
OdGePoint3d startPt = pDbIO->getPoint(DD_T("Get Point"));
//++-- Here we use the method ::createObject() instead of new.
OdDbTablePtr pNewTable = OdDbTable::createObject();
if(pNewTable.isNull())
return;
//++-- This sets the defaults such as layer ...
pNewTable->setDatabaseDefaults(pDb);
pNewTable->setPosition(startPt);
pNewTable->setNumColumns(5);
pNewTable->setNumRows(5);
//++-- you need to do this
pNewTable->generateLayout();
//++-- merge the top row
pNewTable->mergeCells(0,0,0,4);
pNewTable->setTextString(0,0,DD_T("Does this work"));
double textHeight = pDb->getTEXTSIZE();
pNewTable->setRowHeight(textHeight);
pNewTable->setColumnWidth(textHeight * 15);
//++-- Get the modelspace ID
OdDbObjectId spaceId = pDb->getModelSpaceId();
if(spaceId.isNull())
return;
//++-- Open the BTR for write
OdDbBlockTableRecordPtr pBtr = spaceId.openObject(OdDb::kForWrite);
if(pBtr.isNull())
return;
//++-- add the table
pBtr->appendOdDbEntity(pNewTable);
pDbIO->putString(_T("\nDone!"));
}
};
**** Hidden Message *****
页:
[1]