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


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

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


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

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

示例3: AddControls

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

示例4: readDwg

void

readDwg()

{

    // Set constructor parameter to kFalse so that the

    // database will be constructed empty.  This way only

    // what is read in will be in the database.

    //

    AcDbDatabase *pDb = new AcDbDatabase(Adesk::kFalse);



    // The AcDbDatabase::readDwgFile() function

    // automatically appends a DWG extension if it is not

    // specified in the filename parameter.

    //

    if(Acad::eOk != pDb->readDwgFile(_T("./test1.dwg")))

        return;



    // Open the model space block table record.

    //

    AcDbBlockTable *pBlkTbl;

    pDb->getSymbolTable(pBlkTbl, AcDb::kForRead);



    AcDbBlockTableRecord *pBlkTblRcd;

    pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd,

        AcDb::kForRead);

    pBlkTbl->close();



    AcDbBlockTableRecordIterator *pBlkTblRcdItr;

    pBlkTblRcd->newIterator(pBlkTblRcdItr);



    AcDbEntity *pEnt;

    for (pBlkTblRcdItr->start(); !pBlkTblRcdItr->done();

        pBlkTblRcdItr->step())

    {

        pBlkTblRcdItr->getEntity(pEnt,

            AcDb::kForRead);

        acutPrintf(_T("classname: %s\n"),

            (pEnt->isA())->name());

        pEnt->close();

    }

    pBlkTblRcd->close();

    delete pBlkTblRcdItr;

    delete pDb;

}
开发者ID:FengLuanShuangWu,项目名称:AutoCADPlugin-HeatSource,代码行数:85,代码来源:testdb.cpp

示例5: LSS06


//.........这里部分代码省略.........

		Acad::ErrorStatus esResult;
		AcApDocument* pDoc = NULL;
		AcDbDatabase* pDb = NULL;
		bool bFromProject = false;
		bool bReadMyseft = false;

		// Look up the required database from managed documents.
		if (pDoc = findDocument(pszFileName)) {
			CLogger::Print(_T("Inform: found out the database from managed documents."));
			pDb = pDoc->database();
		}

		if (!pDb) {
			// Look up the required database from current opening DENKI project!
			if (!DCMG::IsCacheRunning()) {
				CLogger::Print(_T("Inform: cache is not running > try to get database object."));
				if (pDb = DenkiGetProjectAcDbDatabase(pszFileName)) {
					CLogger::Print(_T("Inform: Database is got from DENKI project."));
				}
			}

			if (!pDb && DCMG::IsCacheRunning()) {
				CLogger::Print(_T("Inform: cache is running > try to open DWG file into DENKI project."));
				if (pDb = DenkiOpenProjectAcDbDatabase(pszFileName)) {
					CLogger::Print(_T("Inform: DWG file is opened into DENKI project. (Need to close it)"));
					bFromProject = true;
				}
			}

			// Open DWG file into an empty database object!
			if (!pDb) {
				pDb = new AcDbDatabase(false, true);
				esResult = pDb->readDwgFile(pszFileName, _SH_DENYNO);
				if (Acad::eOk == esResult) {
					CLogger::Print(_T("Inform: DWG file has been opened into an empty database object! (Need to delete it)"));
					bReadMyseft = true;
				} else {
					delete pDb;
					pDb = NULL;
				}
			}

			if (!pDb) {
				CLogger::Print(_T("Warn: Cannot open dwg file name: '%s' > Ignore"), pszFileName);
				acutPrintf(ACRX_T("Cannot open dwg file name: %s"), pszFileName);
				acdbHostApplicationServices()->setWorkingDatabase(pCurDb);
				continue;
			}
		}

		//------------
		// We have got the database pointer now!
		// Get all of its BlockReferences. Then steps through them.
		AcDbObjectIdArray idaAll;
		int nBlkRefCount = getBlockRefAll(pDb, idaAll);

		CLogger::Print(_T("Inform: Browse all of file's block reference! - Number: %d"), nBlkRefCount);
		for (int nIdx = 0; nIdx < nBlkRefCount; nIdx++) {

			// Get the BlockReference's information!
			DenkiSymbolSnapshot dss;
			if (!dss.open(idaAll[nIdx], ACRX_T("NAME, NAME#*, BAN_NO, INST_NO"))) {
				CLogger::Print(_T("Warn: Fail to open DenkSymbolSnapshot object. > Ignore"));
				continue;
			}
开发者ID:vuonganh1993,项目名称:arxlss,代码行数:67,代码来源:LSS06.cpp

示例6: acutNewRb

void
refEditApiExample()
{

    AcDbObjectId transId;
    AcDbDatabase* pDb;
    char *fname;
    struct resbuf *rb;

    // Get a dwg file from the user.
    //
    rb = acutNewRb(RTSTR);
    int stat = acedGetFileD("Pick a drawing", NULL, "dwg", 0, rb);
    
    if ((stat != RTNORM) || (rb == NULL)) {
        acutPrintf("\nYou must pick a drawing file.");
        return;
    }

    fname = (char*)acad_malloc(strlen(rb->resval.rstring) + 1);
    strcpy(fname, rb->resval.rstring);
    acutRelRb(rb);
    
    // Open the dwg file.
    //
    pDb = new AcDbDatabase(Adesk::kFalse);
    if (pDb->readDwgFile(fname) != Acad::eOk) {
        acutPrintf("\nSorry, that draing is probably already open.");
        return;
    }

    // Get the Block Table and then the model space record.
    //
    AcDbBlockTable *pBlockTable;
    pDb->getSymbolTable(pBlockTable, AcDb::kForRead);
    AcDbBlockTableRecord *pOtherMsBtr;
    pBlockTable->getAt(ACDB_MODEL_SPACE, pOtherMsBtr, AcDb::kForRead);
    pBlockTable->close();

    // Create an iterator.
    //
    AcDbBlockTableRecordIterator *pIter;
    pOtherMsBtr->newIterator(pIter);

    // Set up an object ID array.
    //
    AcDbObjectIdArray objIdArray;

    // Iterate over the model space BTR. Look specifically 
    // for lines and append their object ID to the array.
    //
    for (pIter->start(); !pIter->done(); pIter->step()) {
        AcDbEntity *pEntity;
        pIter->getEntity(pEntity, AcDb::kForRead);

        // Look for only AcDbLine objects and add them to the 
        // object ID array.
        //
        if (pEntity->isKindOf(AcDbLine::desc())) {
            objIdArray.append(pEntity->objectId());
        }
        pEntity->close();
    }
    delete pIter;
    pOtherMsBtr->close();

    if (objIdArray.isEmpty()) {
        acad_free(fname);
        acutPrintf("\nYou must pick a drawing file that contains lines.");
        return;
    }

    // Now get the current database and the object ID for the
    // current database's model space BTR.
    //
    AcDbBlockTable *pThisBlockTable;
    acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pThisBlockTable, AcDb::kForRead);

    AcDbBlockTableRecord *pThisMsBtr;
    pThisBlockTable->getAt(ACDB_MODEL_SPACE, pThisMsBtr, AcDb::kForWrite);
    pThisBlockTable->close();
    
    AcDbObjectId id = pThisMsBtr->objectId();
    pThisMsBtr->close();


    // Create the long transaction. This will check all the entities 
    // out of the external database.
    //
    AcDbIdMapping errorMap;
    acapLongTransactionManagerPtr()->checkOut(transId, objIdArray, id, errorMap);

    // Now modify the color of these entities.
    //
    int colorIndex;
    acedGetInt("\nEnter color number to change entities to: ", &colorIndex);
    AcDbObject* pObj;
    if (acdbOpenObject(pObj, transId, AcDb::kForRead) == Acad::eOk) {

//.........这里部分代码省略.........
开发者ID:kevinzhwl,项目名称:ObjectARXMod,代码行数:101,代码来源:AsdkLongTransSample.cpp


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