当前位置: 首页>>代码示例>>C++>>正文


C++ AcDbDatabase::getBlockTable方法代码示例

本文整理汇总了C++中AcDbDatabase::getBlockTable方法的典型用法代码示例。如果您正苦于以下问题:C++ AcDbDatabase::getBlockTable方法的具体用法?C++ AcDbDatabase::getBlockTable怎么用?C++ AcDbDatabase::getBlockTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AcDbDatabase的用法示例。


在下文中一共展示了AcDbDatabase::getBlockTable方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: acdbHostApplicationServices

Acad::ErrorStatus 
postToDatabase(/*[in]*/AcDbEntity* pEnt,/*[out]*/AcDbObjectId& idObj)
//Purpose:
//  Adds an entity to the MODEL_SPACE of the CURRENT database.
//Note:
//  It could be generalized to add it to any block table record of
//  any database, but why complicate it...
//
{
	Acad::ErrorStatus	  es;
	AcDbBlockTable*		pBlockTable;
	AcDbBlockTableRecord*  pSpaceRecord;
	AcDbDatabase *pCurDwg = acdbHostApplicationServices()->workingDatabase();
    if (pCurDwg==NULL)
        return Acad::eNoDatabase;
    //Get a pointer to the current drawing
    //and get the drawing's block table.  Open it for read.
    if ((es = pCurDwg->getBlockTable(pBlockTable, AcDb::kForRead))==Acad::eOk){
	//Get the Model Space record and open it for write.  This will be the owner of the new line.
        if ((es = pBlockTable->getAt(ACDB_MODEL_SPACE, pSpaceRecord, AcDb::kForWrite))==Acad::eOk){
            //Append pEnt to Model Space, then close it and the Model Space record.
            if ((es = pSpaceRecord->appendAcDbEntity(idObj, pEnt))==Acad::eOk)
                pEnt->close();
            pSpaceRecord->close();
        }
    pBlockTable->close();
    }
	//it is good programming practice to return an error status
	return es;
}
开发者ID:kevinzhwl,项目名称:ObjectARXMod,代码行数:30,代码来源:Lab8CommandUtils.cpp

示例2: getAllSymbolRecordsIds

int getAllSymbolRecordsIds(AcRxClass* pTableClass, AcDbObjectIdArray & idaAll)
{
	CLogger::Print(_T("*Call: getAllSymbolRecordsIds()"));
	Acad::ErrorStatus es;
	idaAll.setLogicalLength(0);

	AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
	AcDbSymbolTable* pSymbolTable = NULL;

	if (AcRx::kEqual == pTableClass->comparedTo(AcDbBlockTable::desc())) {
		CLogger::Print(_T("> This is BlockTable!"));
		es = pDb->getBlockTable(pSymbolTable, AcDb::kForRead);
	}
	else if (AcRx::kEqual == pTableClass->comparedTo(AcDbLayerTable::desc())) {
		CLogger::Print(_T("> This is LayerTable!"));
		es = pDb->getLayerTable(pSymbolTable, AcDb::kForRead);
	}
	else if (AcRx::kEqual == pTableClass->comparedTo(AcDbLinetypeTable::desc())) {
		CLogger::Print(_T("> This is LinetypeTable!"));
		es = pDb->getLinetypeTable(pSymbolTable, AcDb::kForRead);
	}
	else if (AcRx::kEqual == pTableClass->comparedTo(AcDbTextStyleTable::desc())) {
		CLogger::Print(_T("> This is TextStyleTable!"));
		es = pDb->getTextStyleTable(pSymbolTable, AcDb::kForRead);
	}
	else {
		CLogger::Print(_T("*Exit: getAllSymbolRecordsIds() - This kind of SymbolTable is not supported!"));
		return -1;
	}

	if (Acad::eOk != es) {
		CLogger::Print(_T("*Exit: getAllSymbolRecordsIds() -  Fail to get SymbolTable!"));
		return -1;
	}
	
	//------------
	// Get the SymbolTable's iterator.
	AcDbSymbolTableIterator* pSymbolTableIter = NULL;
	es = pSymbolTable->newIterator(pSymbolTableIter);
	pSymbolTable->close();
	if (Acad::eOk != es) {
		CLogger::Print(_T("*Exit: getAllSymbolRecordsIds() - Fail to get the SymbolTable's iterator!"));
		return -1;
	}

	//------------
	// Steps through the SymbolTable's records. 
	// Then get the SymbolTableRecord's ObjectID.
	for (; !pSymbolTableIter->done(); pSymbolTableIter->step()) {
		AcDbObjectId idObj = AcDbObjectId::kNull;
		if (Acad::eOk == pSymbolTableIter->getRecordId(idObj))
			idaAll.append(idObj);
	}

	delete pSymbolTableIter;
	CLogger::Print(_T("*Exit: getAllSymbolRecordsIds() - Count: %02d"), idaAll.length());
	return idaAll.length();
}
开发者ID:vuonganh1993,项目名称:arxlss,代码行数:58,代码来源:LSS08.cpp

示例3: acdbHostApplicationServices

// Add the given entity to the current Database
Acad::ErrorStatus
addToDatabase(AcDbEntity* pEnt, AcDbObjectId& objId)
{
    Acad::ErrorStatus acadReturnValue = Acad::eOk;
    AcDbBlockTable* pBlockTable;
    AcDbBlockTableRecord* pSpaceRecord;

	AcDbDatabase *pCurDwg = acdbHostApplicationServices()->workingDatabase();
    if (pCurDwg==NULL)
        return Acad::eNoDatabase;

    if ((acadReturnValue = pCurDwg->getBlockTable(pBlockTable,
        AcDb::kForRead)) != Acad::eOk) {
        acutPrintf(ACRX_T("\n acdbCurDwg()->getBlockTable() failed"));
        return acadReturnValue;
    }

    if ((acadReturnValue = pBlockTable->getAt(ACDB_MODEL_SPACE, 
        pSpaceRecord, AcDb::kForWrite)) != Acad::eOk) {
        acutPrintf(ACRX_T("\n AcDbBlockTable::getAt() failed"));
        return acadReturnValue;
    }
 
    // close the block table object
    if ((acadReturnValue = pBlockTable->close()) != Acad::eOk) {
        acutPrintf(ACRX_T("\n AcDbBlockTable::close() failed"));
        return acadReturnValue;
    }

    // append the entity to the display list
    if ((acadReturnValue = pSpaceRecord->appendAcDbEntity(objId, pEnt))
        != Acad::eOk) {
        acutPrintf(ACRX_T("\n AcDbBlockTableRecord::appendAcDbEntity() failed"));
        return acadReturnValue;
    }

    // close the block table record object
    if ((acadReturnValue = pSpaceRecord->close()) != Acad::eOk) {
        acutPrintf(ACRX_T("\n AcDbBlockTableRecord::close() failed"));
        return acadReturnValue;
    }

    return acadReturnValue;
}
开发者ID:Bohr27,项目名称:ObjectARXCore,代码行数:45,代码来源:brdbutl.cpp

示例4: append

bool append(AcDbEntity* pEntity)
{
    AcDbBlockTable *pBlockTable;

	AcApDocument* pDoc = acDocManager->curDocument();

	Acad::ErrorStatus es = acDocManager->lockDocument(pDoc);
    if (es != Acad::eOk) {
        acedAlert("Failed to lock the document...");
        return false;
    }

	AcDbDatabase* pDb = pDoc->database();
    
    es = pDb->getBlockTable(pBlockTable, AcDb::kForRead);
    if (es != Acad::eOk) {
        acedAlert("Failed to get block table...");
        return false;
    }

    AcDbBlockTableRecord *pBlockRec;
    es = pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockRec, AcDb::kForWrite);
    if (es != Acad::eOk) {
        acedAlert("Failed to get block table record...");
        pBlockTable->close();
        return false;
    }

    es = pBlockRec->appendAcDbEntity(pEntity);
    if (es != Acad::eOk) {
        acedAlert("Failed to append entity...");
        pBlockTable->close();
        pBlockRec->close();
        delete pEntity;
        return false;
    }
    pBlockRec->close();
    pBlockTable->close();
    return true;

}
开发者ID:kevinzhwl,项目名称:ObjectARXMod,代码行数:41,代码来源:squareui.cpp

示例5:

//When an new entity is added, set its draw order based on the draw order of other entities on the same layer.
void
adskMyDbReactor::objectAppended(const AcDbDatabase* db, const AcDbObject* pObj)
{
	AcDbEntity * pEnt = AcDbEntity::cast(pObj);
	Acad::ErrorStatus es;
	if (pEnt != NULL)
	{
		AcDbBlockTable *pBT = NULL;
		AcDbBlockTableRecord *pBTR	= NULL;
		
		//use transaction since the datbase is still open for write here.
		es=actrTransactionManager->enableGraphicsFlush(true);
		AcTransaction *pTrans = actrTransactionManager->startTransaction() ;
		
		if(!pTrans)
		{
			acutPrintf("\nCan't start transaction!");
			return;
		}
		AcDbObject *pObj = NULL ;
		AcDbDatabase *pDb = NULL;
		AcDbObjectId modelSpaceId;
		pDb = AcDbDatabase::cast(db);
		
		//get AcDbBlockTable for read
		if(Acad::eOk != pDb->getBlockTable(pBT, AcDb::kForRead))
		{
			acutPrintf("can't open block table for read");
			actrTransactionManager->abortTransaction();
			return;
		}
		
		//get the model space object id
		if(Acad::eOk != pBT->getAt( ACDB_MODEL_SPACE, modelSpaceId))
		{
			acutPrintf("\ncan't get model space Id");
			actrTransactionManager->abortTransaction();
			pBT->close();
			return;
		}
		
		pBT->close();
		
		
		//get model space block record for write from transaction
		if (Acad::eOk != pTrans->getObject((AcDbObject*&)pBTR, modelSpaceId, AcDb::kForWrite))
		{
			acutPrintf("\ncan't open model space block table record for write");
			actrTransactionManager->abortTransaction();
			return;
		}
		
		AcDbObjectIdArray eIds;
		
		//get AcDbSortEntsTable
		AcDbSortentsTable *pSortTab = NULL;
		if(Acad::eOk != pBTR->getSortentsTable(pSortTab, AcDb::kForWrite, false))
		{
			acutPrintf("\ncan't get AcDbSortEntsTable for write");
			actrTransactionManager->abortTransaction();
			return;
		}
		
		//put objectIds of all the entities in an Id array.The order of objectIds in the array is the
		//same as their draworders from bottom to top.The newly created entity is always at the top and the last item
		//in the array
		if(Acad::eOk != pSortTab->getFullDrawOrder(eIds))
		{
			acutPrintf("\ncan't get full draworder");
			pSortTab->close();
			actrTransactionManager->abortTransaction();
			return;
		}
		AcDbEntity *pRefEnt = NULL;
		//iterate through the entities in the order of their draworders. If an entity on the same layer is found
		//insert the newly created entity before it.
		int i;
		for(i =0; i<eIds.length(); i++)
		{
			es = pTrans->getObject((AcDbObject*&)pRefEnt, eIds.at(i), AcDb::kForRead);
			if(pRefEnt->layerId() == pEnt->layerId())
				break;
		}	
		eIds.insertAt(i, pEnt->objectId());
		//remove the newly created entity from the end of the array
		eIds.removeLast();
		//reset draworder
		es = pSortTab->setRelativeDrawOrder(eIds);
		pSortTab->close();
		es=actrTransactionManager->endTransaction();
		actrTransactionManager->flushGraphics();

		//set flag for regen
		gbDraworderChanged = true;	
	}

}
开发者ID:kevinzhwl,项目名称:ObjectARXMod,代码行数:98,代码来源:adskMyDbReactor.cpp

示例6: OnCreateLine

void CMyDlg::OnCreateLine() 
{	
	// TODO: Add your control notification handler code here
	acDocManager->lockDocument(curDoc());

	int i;
	int m, n;

	char *buf = (char*)malloc(20);
	
	AcDbObjectId LineId;
	AcDbLine *pLine = NULL;
	//块表
	AcDbBlockTable *pTb = NULL;
	//块表记录
	AcDbBlockTableRecord *pTbr = NULL;
	//层表
	AcDbLayerTable *pLyr = NULL;
	//层表记录
	AcDbLayerTableRecord* pLyrr = NULL;
	//图形数据库
	AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase();
	
	Acad::ErrorStatus es;
	
	CListCtrl *pListCtr = (CListCtrl *)GetDlgItem( IDC_LIST1 );
	
	//设置随机数种子
	srand(time(NULL));
	
	//更新数据
	UpdateData(TRUE);

	m_VecSize += m_Edit5;
	m_xVec.resize(m_VecSize);
	m_yVec.resize(m_VecSize);

	//acutPrintf("%d\n", m_Edit1);
	
	es = pDb->getLayerTable(pLyr, AcDb::kForWrite);	//以写的方式打开层表
	es = pDb->getBlockTable(pTb, AcDb::kForRead);	//以读的方式打开块表
	es = pTb->getAt(ACDB_MODEL_SPACE, pTbr, AcDb::kForWrite);//以写的方式打开块表记录
	
	//创建图层GalLineTest
	if (!pLyr->has("GalLineTest"))
	{
		pLyrr = new AcDbLayerTableRecord;	//创建层记录
		pLyrr->setName("GalLineTest");		//设置名字
		//pLyrr->setColor(color);			//设置颜色
		//pLyrr->setLineWeight(lnWt);		//设置线宽
		
		if (Acad::eOk != pLyr->add(pLyrr))	//添加该层记录到层表
		{
			//添加失败
			delete pLyrr;		//释放内存
			pLyr->close();		//关闭层表
		}
		//关闭层表记录
		pLyrr->close();
	}
	//关闭层表
	pLyr->close();
	
	//生成点坐标
	for (i = 0; i < m_Edit5; ++i)
	{
		if ((m_Edit2 != 0) && (m_Edit4 != 0))
		{
			m_xVec[i] = rand() % m_Edit2 + m_Edit1;
			m_yVec[i] = rand() % m_Edit4 + m_Edit3;
		}
		else
		{
			m_xVec[i] = 0;
			m_yVec[i] = 0;
		}
	}
	
	//遍历点坐标
	for (m = 0; m < m_Edit5; ++m)
	{
		for (n = (m+1); n < m_Edit5; ++n)
		{
			if ((m_xVec[m] != m_xVec[n]) && (m_yVec[m] != m_yVec[n]))
			{
				AcGePoint3d ptStart(m_xVec[m], m_yVec[m], 0);
				AcGePoint3d ptEnd(m_xVec[n], m_yVec[n], 0);
				pLine = new AcDbLine(ptStart, ptEnd);
				//pLine->setColor();
				pLine->setLayer("GalLineTest");
				//创建线段
				es = pTbr->appendAcDbEntity(LineId, pLine);
				if (Acad::eOk == es)
				{
					++m_lLineCnt;
				}
				//acutPrintf("%d\n", LineId);
				sprintf(buf, "%d", LineId);			
				m_ListCtr.InsertItem(m_Row, buf);
				
//.........这里部分代码省略.........
开发者ID:trist725,项目名称:GalCreateLines,代码行数:101,代码来源:MyDlg.cpp


注:本文中的AcDbDatabase::getBlockTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。