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


C++ AcDbDatabase类代码示例

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


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

示例1: readDatabase

void readDatabase()
{
	// Use kFalse to create an empty database.
    AcDbDatabase *pDb = new AcDbDatabase(Adesk::kFalse);

    // Use readDwgFile to load the DWG file.
	acutPrintf(_T("\nRead file \"d:\\temp\\testfile.dwg\"."));
    if(Acad::eOk != pDb->readDwgFile(_T("d:\\temp\\testfile.dwg")))
        return;

    // Get the BlockTable.
    AcDbBlockTable *pBTable = NULL;
    pDb->getSymbolTable(pBTable, AcDb::kForRead);

	// Get the ModelSpace.
    AcDbBlockTableRecord *pRecord = NULL;
    pBTable->getAt(ACDB_MODEL_SPACE, pRecord, AcDb::kForRead);
    pBTable->close();

	// Get new iterator.
    AcDbBlockTableRecordIterator *pItr = NULL;
    pRecord->newIterator(pItr);

    AcDbEntity *pEnt = NULL;
    for (pItr->start(); !pItr->done(); pItr->step())
    {
        pItr->getEntity(pEnt, AcDb::kForRead);
        acutPrintf(_T("\nclassname: %s"), (pEnt->isA())->name());
        pEnt->close();
    }
    pRecord->close();
    delete pItr;
    delete pDb;
}
开发者ID:kevinzhwl,项目名称:ZRXSDKMod,代码行数:34,代码来源:DatabaseOp.cpp

示例2: getDestDb

void
ArxDbgUiTdcWblockClone::doInsertOption(AcDbDatabase* tmpDb)
{
    AcDbDatabase* destDb = getDestDb();
    if (destDb == NULL) {
        ArxDbgUiTdmDatabase dbox(tmpDb, this, _T("Wblock'd Database"));
        dbox.DoModal();

        doSaveOption(tmpDb);
    }
    else {
        Acad::ErrorStatus es;

            // lock the document we are inserting into
        ArxDbgDocLockWrite docLock(destDb);
        if (docLock.lockAndSetCurrent() != Acad::eOk)
            return;

        es = destDb->insert(AcGeMatrix3d::kIdentity, tmpDb, false);
        if (es == Acad::eOk) {
            ArxDbgUiTdmDatabase dbox(destDb, this, _T("Wblock/Insert Database"));
            dbox.DoModal();

            doSaveOption(destDb);
        }
        else {
            CString str;
            str.Format(_T("Insert failed: %s"), ArxDbgUtils::rxErrorStr(es));
            ArxDbgUtils::stopAlertBox(str);
        }
    }
}
开发者ID:FengLuanShuangWu,项目名称:AutoCADPlugin-HeatSource,代码行数:32,代码来源:ArxDbgUiTdcWblockClone.cpp

示例3: SaveToFile

bool CMakeBlkFile::SaveToFile()
{
	bool bRet = true;
	AcDbDatabase *pDwg = NULL; 
	Acad::ErrorStatus es;

	es = acdbHostApplicationServices()->workingDatabase()->wblock(pDwg, m_objIdArrs, m_insertPt/*, AcDb::kDrcIgnore*/);
	if (es == Acad::eOk)
	{
		AcDb::AcDbDwgVersion dwgVer = acdbHostApplicationServices()->workingDatabase()->originalFileVersion();
		es = pDwg->saveAs(m_strFileName,FALSE,dwgVer,0);
		if (es!=Acad::eOk)
		{
			bRet = false;
		}
	}
	if (pDwg != NULL)
	{
		delete pDwg;
		pDwg = NULL;
	}

	acTransactionManagerPtr()->queueForGraphicsFlush();
	acTransactionManagerPtr()->flushGraphics();//刷新
	acedUpdateDisplay();
	return bRet;
}
开发者ID:kanbang,项目名称:SVN,代码行数:27,代码来源:MakeBlkFile.cpp

示例4: 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

示例5: postToDatabase

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

示例6: SetCurLayler

void Additional_Class::SetCurLayler( AcDbObjectId curlayerID)
{
	AcDbDatabase *pCurDb = NULL;
	pCurDb = acdbHostApplicationServices()->workingDatabase();
	pCurDb->setClayer(curlayerID);
	return;
}
开发者ID:TobeGodman,项目名称:AutoTrader,代码行数:7,代码来源:Additional_Class.cpp

示例7: GetWorkingDB

Acad::ErrorStatus TWArxLayerMan::Init()
{
	AcDbDatabase* pDb = GetWorkingDB();

	Acad::ErrorStatus es = Acad::eOk;

	AcDbLayerTable* pLayerTb = NULL;
	es = pDb->getLayerTable( pLayerTb,AcDb::kForRead );
	if( pLayerTb == NULL ) return es;
	pLayerTb->close();

	AcDbLayerTableIterator* pIte = NULL;
	es = pLayerTb->newIterator( pIte );
	if( pIte == NULL ) return es;

	m_vLayers.clear();
	for ( pIte->start(); !pIte->done(); pIte->step())
	{
		AcDbObjectId Id;
		es = pIte->getRecordId( Id );
		if( es != Acad::eOk ) continue;

		m_vLayers.push_back( Id );
	}

	TWFreePtr( pIte );
	return es;
}
开发者ID:jiangnanemail,项目名称:WorkingDB,代码行数:28,代码来源:TWArxTool.cpp

示例8: acutPrintf

void
ArxDbgUiTdcSysReactors::attachTransactionReactorToAll()
{
    if (m_transReactor) {
		AcDbDatabase* tmpDb;
		AcDbVoidPtrArray dbPtrs;
		ArxDbgUtils::getAllDatabases(dbPtrs);

		AcDbTransactionManager* tmpTrMgr;
		AcDbVoidPtrArray trMgrs;	// keep track of ones we've attached to since some db's share transMgr

        acutPrintf(_T("\nAttaching Transaction Reactor to all active databases..."));

		int len = dbPtrs.length();
		for (int i=0; i<len; i++) {
			tmpDb = static_cast<AcDbDatabase*>(dbPtrs[i]);

			tmpTrMgr = tmpDb->transactionManager();
			if (tmpTrMgr && (trMgrs.contains(tmpTrMgr) == false)) {
				tmpTrMgr->addReactor(m_transReactor);
				trMgrs.append(tmpTrMgr);
			}
			else {
				CString str;
				acutPrintf("\nSkipping duplicate transaction manager for: (%s)", ArxDbgUtils::dbToStr(tmpDb, str));
			}
		}
	}
}
开发者ID:kevinzhwl,项目名称:ObjectARXMod,代码行数:29,代码来源:ArxDbgUiTdcSysReactors.cpp

示例9: _T

void
ArxDbgUiTdcInsert::OnAddExternalDwg()
{
	CString fname;
	Acad::ErrorStatus es;
	es = ArxDbgUtils::getFileNameForRead(_T("Drawing File"), NULL, _T("dwg"),
                       fname, false, false);

	if (es == Acad::eOk) {
		if (hasDwgFile(m_extDwgNames, fname))
			ArxDbgUtils::alertBox(_T("That DWG file is already in the list."));
		else {
			AcDbDatabase* db = new AcDbDatabase(false, true);
			es = db->readDwgFile(fname);

			if (es == Acad::eOk) {
				m_dbPtrs.append(db);
				m_extDwgNames.Add(fname);

				CString str;
				ArxDbgUtils::dbToStr(db, str);
				m_lbSourceDb.AddString(str);
				m_lbDestDb.AddString(str);
			}
			else {
				CString str;
				str.Format(_T("ERROR: could not read DWG file: %s"), ArxDbgUtils::rxErrorStr(es));
				ArxDbgUtils::alertBox(str);
			}
		}
	}
}
开发者ID:kevinzhwl,项目名称:ObjectARXMod,代码行数:32,代码来源:ArxDbgUiTdcInsert.cpp

示例10: acdbCurDwg

Acad::ErrorStatus CTwArxDictionary::CreateSubDictionaryID( IN const AcDbObjectId& IdRoot, IN const CString& strKey, OUT AcDbObjectId& IdSubDic, IN AcRxClass* pRxObjType /*= AcDbDictionary::desc() */ ) const
{
	if( pRxObjType == NULL ) return Acad::eNullObjectPointer;

	Acad::ErrorStatus es = Acad::eOk;
	AcDbDictionary* pDicRoot = NULL;
	AcDbDatabase* pWdb = acdbCurDwg();

	if( IdRoot.isNull() )
		es = pWdb->getNamedObjectsDictionary( pDicRoot, AcDb::kForRead );
	else
		es = acdbOpenObject( pDicRoot, IdRoot, AcDb::kForRead );

	if( es != Acad::eOk ) return es;

	if( pDicRoot->has(strKey) )
	{
		pDicRoot->getAt( strKey, IdSubDic );
		pDicRoot->close();
		return es;
	}

	pDicRoot->upgradeOpen();
	AcDbObject* pObj = (AcDbObject*)pRxObjType->create();
	es = pDicRoot->setAt( strKey, pObj, IdSubDic );
	pObj->close();
	pDicRoot->close();

	return es;
}
开发者ID:jiangnanemail,项目名称:WorkingDB,代码行数:30,代码来源:TWArxTool.cpp

示例11: GetClientRect

void CZhfPalette::AddControls()
{
	acDocManager->lockDocument(curDoc(), AcAp::kWrite, NULL, NULL, true) ;
	CRect rect ;
	GetClientRect(&rect) ;
	int iWidth = rect.Width() ;
	int iHeight = rect.Height() ;

	CFont * pFont = new CFont;
	pFont->CreateFont(14, // nHeight
		0, // nWidth
		0, // nEscapement
		0, // nOrientation
		FW_NORMAL , // nWeight
		FALSE, // bItalic
		FALSE, // bUnderline
		0, // cStrikeOut
		ANSI_CHARSET, // nCharSet
		OUT_DEFAULT_PRECIS, // nOutPrecision
		CLIP_DEFAULT_PRECIS, // nClipPrecision
		DEFAULT_QUALITY, // nQuality
		DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
		_T("Arial")); // lpszFac


	int iIndex = 0 ;
	int iCount = m_strArrayFile.GetCount() ;
	for (int i=0; i<iCount; i++)
	{
		CString strFile = m_strArrayFile.GetAt(i) ;

		CGsPreviewCtrl* pCtrl = new CGsPreviewCtrl() ;
		pCtrl->m_iIndex = iIndex ;
		pCtrl->m_strDwgFile = strFile ;
		m_pArrayPreviewCtrl.Add(pCtrl) ;
		pCtrl->Create(_T(""), WS_CHILD|WS_VISIBLE|SS_CENTER|SS_SUNKEN, CRect(10, 10, 110, 110), this) ;
		
		AcDbDatabase* pDbSrc = new AcDbDatabase(false) ;
		if(Acad::eOk==pDbSrc->readDwgFile(strFile))
		{
			AcDbDatabase* pDbTo = new AcDbDatabase() ;
			this->Wblock(pDbSrc, pDbTo) ;
			this->FilterDb(pDbTo, m_nArrayFilterMode.GetAt(i)) ;

			pCtrl->SetDatabase(pDbTo);
		}
		delete pDbSrc ;		

		CStatic* pCtrlStatic = new CStatic() ;
		CString strFileName ;
		strFileName.Format(_T("%s"), m_strArrayFileName.GetAt(i)) ;		
		m_pArrayStatic.Add(pCtrlStatic) ;
		pCtrlStatic->Create(strFileName, WS_CHILD|WS_VISIBLE|SS_CENTER, CRect(10, 10, 40, 110), this) ;
		pCtrlStatic->SetFont(pFont) ;
		iIndex++ ;
	}
	acDocManager->unlockDocument(curDoc()) ;
	this->OnSize(0, iWidth, iHeight) ;
}
开发者ID:luosin,项目名称:cad-2004-lzx,代码行数:59,代码来源:ZhfPalette.cpp

示例12: ads_MyDialog

  int ads_MyDialog()
  {
// sample from brxtemplate

//++-- See StdAfx for these types
  StringPairs LayerList;

  AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase();
    pDb->layerTableId();

  LayerTablePointer pLayerTable(pDb->layerTableId(),AcDb::kForRead);

    if(pLayerTable.openStatus() != eOk)
    {
      ads_retnil();
      return( RSRSLT);
    }

  AcDbLayerTableIterator *pLayerTableIterator;
    pLayerTable->newIterator(pLayerTableIterator);

    //++-- iterate though and get our stuff
    for (pLayerTableIterator->start(); 
        !pLayerTableIterator->done(); 
         pLayerTableIterator->step())
    {
    AcDbObjectId LayerId;
    TCHAR *LayerName;
    CString LayerColor;


      pLayerTableIterator->getRecordId(LayerId);
      LayerTableRecordPointer pLayerTableRecord(LayerId,AcDb::kForRead);
      pLayerTableRecord->getName(LayerName);
    AcCmColor clr = pLayerTableRecord->color();
      LayerColor = clr.bookName();

      LayerColor.Format(_T("Red = %03d   Green = %03d   Blue = %03d "), 
                           clr.red(),    clr.green() ,  clr.blue());

      LayerList.push_back(StringPair(String(LayerName), String(LayerColor)));
    }

    delete pLayerTableIterator;
    {
    // you should always call this before your diaog;
    CAcModuleResourceOverride resOverride;

    //show our dialog
      MyDialog dlg(LayerList,CWnd::FromHandle(adsw_acadMainWnd()));
      dlg.DoModal();
    }
    ads_retnil();
    return( RSRSLT);

 }
开发者ID:billmuell,项目名称:GeoMap,代码行数:56,代码来源:MyFunctions.cpp

示例13: AddEntityToDataBase

static void AddEntityToDataBase(AcDbEntity *pEnt) 
  {
    AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
    AcDbBlockTableRecordPointer pBTR(pDb->currentSpaceId(), AcDb::kForWrite); 
    if (pEnt && Acad::eOk == pBTR.openStatus())
    {
      pBTR->appendAcDbEntity(pEnt);
      pEnt->close();
    }
  }
开发者ID:vpatrinica,项目名称:pernute,代码行数:10,代码来源:InteriorPointsConstructor.cpp

示例14: GetPredefinedStrings

//OPM calls this function for each property to obtain a list of strings and cookies if they are available.
//For our textstyle property we would like to display all the textstyles currently available in the database.
//This function is declared on the IPerPropertyBrowsing interface. Our IOPMPropertyExtensionImpl
//class implements this member by reading the values in the OPM property map. (You set this up in your
//head file when you use BEGIN_OPMPROP_MAP, OPMPROP_ENTRY, END_OPMPROP_MAP macros.)
//Since we need a dynamic list of entries in this drop down list and a static map cannot implement this, 
//we need to override this function a provide dynamic list of text styles to OPM.
STDMETHODIMP CComPolygon::GetPredefinedStrings(DISPID dispID, CALPOLESTR *pCaStringsOut, CADWORD *pCaCookiesOut)
{
    if (dispID != DISPID_TEXTSTYLENAME)
        return  IOPMPropertyExtensionImpl<CComPolygon>::GetPredefinedStrings(dispID,pCaStringsOut,pCaCookiesOut);
    USES_CONVERSION;
    AcDbTextStyleTable* pTT;
    
    AcDbDatabase *pDb = m_objRef.objectId().database();
    if (NULL == pDb)
        pDb = acdbHostApplicationServices()->workingDatabase();
    
    if (pDb->getTextStyleTable(pTT,AcDb::kForRead)==Acad::eOk)
    {
        AcDbTextStyleTableIterator* pIter;
        if (pTT->newIterator(pIter)==Acad::eOk)
        {
            long size = 0;

            // Clear the array.
            mObjectIdArray.removeAll();

            for (pIter->start();!pIter->done();pIter->step())
                size++;
            pCaStringsOut->pElems = (LPOLESTR *)::CoTaskMemAlloc(sizeof(LPOLESTR) * size);
            pCaCookiesOut->pElems = (DWORD *)::CoTaskMemAlloc(sizeof(DWORD) * size);
            long i=0;
            for (pIter->start();!pIter->done();pIter->step())
            {
                AcDbTextStyleTableRecord* pTTR;
                if (pIter->getRecord(pTTR,AcDb::kForRead)!=Acad::eOk)
                    continue;
                const TCHAR* pName = NULL;
                if (pTTR->getName(pName)==Acad::eOk){
                    //we want to show the name of the textstyle as 
                    //it appears in the database
                    pCaStringsOut->pElems[i] = ::SysAllocString(CT2W(pName));
                    pCaCookiesOut->pElems[i] = mObjectIdArray.append(pTTR->objectId());
                }
                pTTR->close();
                i++;
            }
            pCaStringsOut->cElems = i;
            pCaCookiesOut->cElems = i;
        }
        if (pIter)
            delete pIter;
        pTT->close();
    }
    return S_OK;
}
开发者ID:FengLuanShuangWu,项目名称:AutoCADPlugin-HeatSource,代码行数:57,代码来源:compolygon.cpp

示例15: UpdateData

void
ArxDbgUiTdcInsert::OnInsertBlkDef()
{
	CString blkName;
	m_ebDestName1.GetWindowText(blkName);

	if (!acdbSNValid(blkName, false)) {
		CString str;
		str.Format(_T("%s is not a valid block name."), blkName);
		ArxDbgUtils::alertBox(str);
		return;
	}

	UpdateData(TRUE);

	bool isExternal;
	AcDbDatabase* sourceDb = getSourceDb(isExternal);
	AcDbDatabase* destDb = getDestDb();
	ASSERT(sourceDb != destDb);

	Acad::ErrorStatus es;

		// lock the document we are inserting into
	ArxDbgDocLockWrite docLock(destDb);
	if (docLock.lockAndSetCurrent() != Acad::eOk)
		return;

	bool preserveSrcDb = intToBool(m_preserveOriginalDb);
	if (!preserveSrcDb && !isExternal) {
		ArxDbgUtils::alertBox(_T("Ignoring setting of \"Preserve source database\" since destroying\na database associated with a Document would be harsh."));
		preserveSrcDb = true;
	}

	AcDbObjectId blkId;
	es = destDb->insert(blkId, blkName, sourceDb, preserveSrcDb);
	if (es == Acad::eOk) {
		ArxDbgUiTdmDatabase dbox(destDb, this, _T("Inserted Database"));
		dbox.DoModal();

		doSaveOption(destDb);

		if (isExternal && !preserveSrcDb)
			reloadRaidedExternalDwg(sourceDb);
	}
	else {
		CString str;
		str.Format(_T("Insert failed: %s"), ArxDbgUtils::rxErrorStr(es));
		ArxDbgUtils::stopAlertBox(str);
	}
}
开发者ID:kevinzhwl,项目名称:ObjectARXMod,代码行数:50,代码来源:ArxDbgUiTdcInsert.cpp


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