Esempio n. 1
1
// 查找连接点junctionPt关联的分支图元(包含隐形的图元)
static void FindLinesByPoint( const AcGePoint3d& junctionPt, AcDbObjectIdArray& objIds )
{
    AcDbBlockTable* pBlkTbl;
    acdbHostApplicationServices()->workingDatabase()->getSymbolTable( pBlkTbl, AcDb::kForRead );

    AcDbBlockTableRecord* pBlkTblRcd;
    pBlkTbl->getAt( ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForRead );
    pBlkTbl->close();

    AcDbBlockTableRecordIterator* pBlkTblRcdItr;
    pBlkTblRcd->newIterator( pBlkTblRcdItr );

    for ( pBlkTblRcdItr->start(); !pBlkTblRcdItr->done(); pBlkTblRcdItr->step() )
    {
        // 不采用transaction的方法查找LinkedGE,
        // 等价于排除当前正在以write状态编辑的LinkedGE
        // 重要(***)
        AcDbEntity* pEnt = 0;
        if( Acad::eOk != pBlkTblRcdItr->getEntity( pEnt, AcDb::kForRead ) ) continue;

        LinkedGE* pEdge = LinkedGE::cast( pEnt );
        if( pEdge != 0 )
        {
            AcGePoint3d startPt, endPt;
            pEdge->getSEPoint( startPt, endPt );
            if( startPt == junctionPt || endPt == junctionPt )
            {
                objIds.append( pEdge->objectId() );
            }
        }
        pEnt->close();
    }
    delete pBlkTblRcdItr;
    pBlkTblRcd->close();
}
Esempio n. 2
1
Acad::ErrorStatus createCircle(AcDbObjectId & idCircle)
{
	CLogger::Print(L"*Call: createCircle()");
	Acad::ErrorStatus es, esTmp;

	AcDbBlockTable* pBlockTable = NULL;
	es = acdbHostApplicationServices()->workingDatabase()
				->getSymbolTable(pBlockTable, AcDb::kForRead);
	if (Acad::eOk != es) {
		CLogger::Print(L"*Exit: createCircle() - Fail to get the BlockTable.");
		return es;
	}

	AcDbBlockTableRecord* pModelSpace = NULL;
	es = pBlockTable->getAt(ACDB_MODEL_SPACE, pModelSpace, AcDb::kForWrite);
	if (Acad::eOk != (esTmp =  pBlockTable->close())) {
		CLogger::Print(L"Warn: Fail to close the BlockTable!");
		acrx_abort(ACRX_T("\nThere is an error occured when close the BlockTable. Message: %s")
									, acadErrorStatusText(esTmp));
	}
	if (Acad::eOk != es) {
		CLogger::Print(L"*Exit: createCircle() - Fail to get the Model Space! Error: %s", acadErrorStatusText(es));
		return es;
	}

	idCircle = AcDbObjectId::kNull;
	AcGePoint3d pt3Center(9.0, 3.0, 0.0);
	AcGeVector3d vt3Normal(0.0, 0.0, 1.0);
	AcDbCircle* pCircle = new AcDbCircle(pt3Center, vt3Normal, 10.0);

	if (!pCircle) {
		if (Acad::eOk != (esTmp = pModelSpace->close())) {
			CLogger::Print(L"Warn: Fail to create new circle object!");
			acrx_abort(ACRX_T("\nThere is an error occured. Error: %s")
											, acadErrorStatusText(esTmp));
		}
		return Acad::eOutOfMemory;
	}

	es = pModelSpace->appendAcDbEntity(idCircle, pCircle);
	if (Acad::eOk != (esTmp = pModelSpace->close())) {
		CLogger::Print(L"Warn: Fail to close the Model Space!");
		acrx_abort(ACRX_T("\nThere is an error occured when close the Model Space! Error: %s")
										, acadErrorStatusText(esTmp));
	}
	if (Acad::eOk != es) {
		CLogger::Print(L"*Exit: createCircle() - Fail to append new circle in to Model Space!");
		delete pCircle;
		return es;
	}

	if (Acad::eOk != (esTmp = pCircle->close())) {
		CLogger::Print(L"Warn: Fail to close the circle object.");
		acrx_abort(ACRX_T("\nFail to close the circle entity!, Error: %s")
										, acadErrorStatusText(esTmp));
	}

	CLogger::Print(L"*Exit: createCircle()");
	return Acad::eOk;
}
Esempio n. 3
0
AcDbObjectId CreateTextStyle(const CString& style, const CString& winFont, Adesk::Boolean bold, Adesk::Boolean italic, int charset, int pitchAndFamily)
{
	/*
	//pTextStyleTblRcd->setFileName(_T("simfang.ttf"));
	//pTextStyleTblRcd->setBigFontFileName("hzdx");
	pTextStyleTblRcd->setXScale(0.8);
	//pTextStyleTblRcd->setFont("_T(楷体_GB2312"),Adesk::kFalse,Adesk::kFalse,GB2312_CHARSET,49);
	//pTextStyleTblRcd->setFont(_T("宋体"),Adesk::kFalse,Adesk::kFalse,GB2312_CHARSET,2);
	pTextStyleTblRcd->setFont(winFont,Adesk::kFalse,Adesk::kFalse,GB2312_CHARSET,16);
	*/

	AcDbTextStyleTable *pTextStyleTbl;
	acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pTextStyleTbl, AcDb::kForWrite);
	AcDbObjectId fontId;
	if(pTextStyleTbl->getAt(style, fontId) == Acad::eKeyNotFound)
	{
		AcDbTextStyleTableRecord *pTextStyleTblRcd=new AcDbTextStyleTableRecord;
		pTextStyleTblRcd->setName(style);
		pTextStyleTblRcd->setFont(winFont,bold,italic,charset,pitchAndFamily);
		pTextStyleTbl->add(fontId,pTextStyleTblRcd);
		pTextStyleTblRcd->close();
	}
	pTextStyleTbl->close();

	return fontId;
	//acdbHostApplicationServices()->workingDatabase()->setTextstyle(fontId);
}
Esempio n. 4
0
void ModifyLayerProp()
{
	CString strLayerName(_T("NewLayer"));

	AcDbLayerTable* pLayerTbl = NULL;
	acdbHostApplicationServices()->workingDatabase()->getLayerTable(pLayerTbl, AcDb::kForRead);

	if (!pLayerTbl->has(strLayerName))
	{
		pLayerTbl->close();
		acutPrintf(_T("\nNo existed layer:\"%s\"."), strLayerName);
		return;
	}

	Acad::ErrorStatus es;
	AcDbLayerTableRecord* pLayerTblRcd = NULL;
	pLayerTbl->getAt(strLayerName, pLayerTblRcd, AcDb::kForWrite);

	AcCmColor oldColor = pLayerTblRcd->color();
	int nCurColor = oldColor.colorIndex();
	int nNewColor = oldColor.colorIndex();

	if (acedSetColorDialog(nNewColor, Adesk::kFalse, nCurColor))
	{
		AcCmColor color;
		color.setColorIndex(nNewColor);
		pLayerTblRcd->setColor(color);
		acutPrintf(_T("\nThe color of  layer:\"%s\" has modified!"), strLayerName);
	}

	pLayerTblRcd->close();
	pLayerTbl->close();
}
Esempio n. 5
0
	//-------------------------------------------------------------------------------------------
	// 
	//  功能: 遍历线型表中的所有记录,获得并打印线型名
	//                 
	//
	//  作者:Qin H.X.
	//
	// 日期:200709
	//
	//  历史:无
	//
	//----------------------------------------------------------------------------------------------
	// - CGDCH03.IterateLinetype command (do not rename)
	static void CGDCH03IterateLinetype(void)
	{
		// 获取线型表
		AcDbLinetypeTable *pLinetypeTbl;
		acdbHostApplicationServices()->workingDatabase()
			->getSymbolTable(pLinetypeTbl, AcDb::kForRead);

		// 创建线性表的遍历器
		AcDbLinetypeTableIterator *pLtIterator;
		pLinetypeTbl->newIterator(pLtIterator);

		// 遍历线性表,输出每个线性表记录的名称
		AcDbLinetypeTableRecord *pLtTableRcd;
		const TCHAR *pLtName;
		for (; !pLtIterator->done(); pLtIterator->step()) {
			pLtIterator->getRecord(pLtTableRcd, AcDb::kForRead);
			pLtTableRcd->getName(pLtName);
			pLtTableRcd->close();
			acutPrintf(_T("\n线型名称:  %s"), pLtName);
		}
		// 删除线性表遍历器并关闭线性表
		delete pLtIterator;
		pLinetypeTbl->close();

	}
Esempio n. 6
0
void ArxDictTool::RegDict( const CString& dictName )
{
    // 初始化工作,建立存储词典
    AcDbDictionary* pNamedobj;
    acdbHostApplicationServices()->workingDatabase()->getNamedObjectsDictionary( pNamedobj, AcDb::kForWrite );

    AcDbObject* pObj;
    Acad::ErrorStatus es = pNamedobj->getAt( dictName, pObj, AcDb::kForRead );
    if( Acad::eOk ==  es )
    {
        pObj->close();
    }
    else if( Acad::eKeyNotFound == es )
    {
        AcDbDictionary* pDict = new AcDbDictionary();
        AcDbObjectId dictId;
        if( Acad::eOk != pNamedobj->setAt( dictName, pDict, dictId ) )
        {
            delete pDict;
        }
        else
        {
            pDict->close();
        }
    }
    pNamedobj->close();
}
Esempio n. 7
0
void Additional_Class::SetCurLayler( AcDbObjectId curlayerID)
{
	AcDbDatabase *pCurDb = NULL;
	pCurDb = acdbHostApplicationServices()->workingDatabase();
	pCurDb->setClayer(curlayerID);
	return;
}
Esempio n. 8
0
// Opens the linetype table and iterates through all the
// entries printing the name of each linetype.
// 
// THE FOLLOWING CODE APPEARS IN THE SDK DOCUMENT.
//
void
iterateLinetypes()
{
    AcDbLinetypeTable *pLinetypeTbl;
    acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pLinetypeTbl, AcDb::kForRead);

    // Create a new iterator that starts at table
    // beginning and skips deleted.
    //
    AcDbLinetypeTableIterator *pLtIterator;
    pLinetypeTbl->newIterator(pLtIterator);

    // Walk the table, getting every table record and
    // printing the linetype name.
    //
    AcDbLinetypeTableRecord *pLtTableRcd;
    const char *pLtName;
    for (; !pLtIterator->done(); pLtIterator->step()) {
        pLtIterator->getRecord(pLtTableRcd, AcDb::kForRead);
        pLtTableRcd->getName(pLtName);
        pLtTableRcd->close();
        acutPrintf("\nLinetype name is:  %s", pLtName);
    }
    delete pLtIterator;
    pLinetypeTbl->close();
}
Esempio n. 9
0
//This is the entry point that makes a simple DLL an ARX.
//This entry point must be exported either by means of a def file
//or by the means of _declspec
extern "C" AcRx::AppRetCode
acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt) 
{
    switch (msg) {
    case AcRx::kInitAppMsg:
        //An ARX application is locked to memory by default.
        //You must make the following function call to unlock
        //it.
        acrxDynamicLinker->unlockApplication(pkt); 
		//support MDI
		acrxDynamicLinker->registerAppMDIAware(pkt);
       //Create transient object reactor
        pAsdkLab7ObjectReactor = new AsdkLab7ObjectReactor;

		// Add the database and the object reactors to the actual doc
		// For the other documents these will be added on document activation
		assert ( chEmployeesInfo.m_pDbReactor == NULL );
		chEmployeesInfo.m_pDbReactor = new AsdkLab7DbReactor();
		acdbHostApplicationServices()->workingDatabase()->addReactor(chEmployeesInfo.m_pDbReactor);

		attachReactorToAllEmployee(true);

		//Create the editor reactor - not document specific
        CreateMyEditorReactor();
        break;
    case AcRx::kUnloadAppMsg:
        //Delete the editor reactor
        EraseMyEditorReactor();
		//Delete the transient object reactor
        if (pAsdkLab7ObjectReactor)
            delete pAsdkLab7ObjectReactor;
        break;
   }
    return AcRx::kRetOK;
}
Acad::ErrorStatus postToDatabase (/*[in]*/AcDbDatabase *pDb /*=NULL*/, AcDbEntity *pEnt, AcDbObjectId &idObj) {
    //----- Purpose:
    //----- Adds an entity to the MODEL_SPACE of the database given in argument.
    //-----   * pDb:   pointer to the databse where to add the entity,
    //-----            if NULL, then the curretn database is used.
    //-----   * pEnt:  pointer to an entity instance.
    //-----   * idObj: it will contain the assign ID to the object if successfully added to the database.
    //----- Note:
    //-----   The entity object is closed while we return from that function. Only the idObj can be used after.
    assert ( pEnt != NULL ) ;

    if ( pDb == NULL )
        pDb =acdbHostApplicationServices ()->workingDatabase () ;
    //----- Get a pointer to the current drawing
    //----- and get the drawing's block table. Open it for read.
    Acad::ErrorStatus es ;
    AcDbBlockTable *pBlockTable ;
    if ( (es =pDb->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.
        AcDbBlockTableRecord *pSpaceRecord ;
        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) ;
}
Esempio n. 11
0
void
makeABlock()
{
     // Create and name a new block table record.
     //
     AcDbBlockTableRecord *pBlockTableRec
         = new AcDbBlockTableRecord();
     pBlockTableRec->setName("ASDK-NO-ATTR");

     // Get the block table.
     //
     AcDbBlockTable *pBlockTable = NULL;
     acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pBlockTable, AcDb::kForWrite);

     // Add the new block table record to the block table.
     //
     AcDbObjectId blockTableRecordId;
     pBlockTable->add(blockTableRecordId, pBlockTableRec);
     pBlockTable->close();

     // Create and add a line entity to the component's
     // block record.
     //
     AcDbLine *pLine = new AcDbLine();
     AcDbObjectId lineId;

     pLine->setStartPoint(AcGePoint3d(3, 3, 0));
     pLine->setEndPoint(AcGePoint3d(6, 6, 0));
     pLine->setColorIndex(3);

     pBlockTableRec->appendAcDbEntity(lineId, pLine);
     pLine->close();
     pBlockTableRec->close();
}
Esempio n. 12
0
static Acad::ErrorStatus 
stylePoly(AsdkPoly* poly)
{
    Acad::ErrorStatus es = Acad::eOk;
    
    char nameBuf[133];
    int as;
    if ((as = acedGetString(Adesk::kTrue, "\nEnter new text style: ", 
        nameBuf)) == RTNORM) {
        // NULL string.
        if (strlen(nameBuf) == 0)
            return Acad::eOk;
        AcDbObjectId tsId;
        if ((es = rx_getTextStyleId(nameBuf, 
                acdbHostApplicationServices()->workingDatabase(), 
                tsId)) != Acad::eOk)
            return es;
        if ((es = poly->upgradeOpen()) != Acad::eOk) {
            return es;
        }
        if ((es = poly->setTextStyle(tsId)) != Acad::eOk) {
            poly->downgradeOpen();
            return es;
        }
        return poly->downgradeOpen();
    } else if (as == RTCAN)
        return Acad::eOk;
    else
        return Acad::eInvalidInput;
}
Esempio n. 13
0
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;
}
// The list tree function runs through all objects in the ASDK_DICT dictionary,
// follows their ownership trees, and lists out information
// on all objects in the tree.
//
void
listTree()
{
    AcDbDictionary *pNamedobj;
    AcDbDictionary *pDict;
    acdbHostApplicationServices()->workingDatabase()
        ->getNamedObjectsDictionary(pNamedobj, AcDb::kForWrite);

    // Get a pointer to the ASDK_DICT dictionary.
    //
    if (pNamedobj->getAt(_T("ASDK_DICT"), (AcDbObject*&) pDict,
        AcDb::kForRead) == Acad::eKeyNotFound)
	{
		pNamedobj->close();
		return ;
	}

    pNamedobj->close();

    // Run through the entries and list their backpointers.
    //
    AcDbDictionaryIterator *pDictItr = pDict->newIterator();
    for (; !pDictItr->done(); pDictItr->next()) {
        printOut(pDictItr->objectId());
    }
    delete pDictItr;

    pDict->close();
}
STDMETHODIMP CComPolygon::put_TextStyleName(BSTR newVal)
{
	try
    {
        AXEntityDocLockNoDbOk(m_objRef.objectId());

        Acad::ErrorStatus es;
        AcAxObjectRefPtr<AsdkPoly> pPoly(&m_objRef,AcDb::kForWrite,Adesk::kTrue);
	    if((es=pPoly.openStatus()) != Acad::eOk)
            throw es;

        USES_CONVERSION;
        AcDbDatabase* pDb = m_objRef.objectId().database();
        if (NULL == pDb)
            pDb = acdbHostApplicationServices()->workingDatabase();
        
        AcDbTextStyleTableRecordPointer pTextStyleRecord(W2T(newVal),pDb,AcDb::kForRead);
        if((es=pTextStyleRecord.openStatus()) != Acad::eOk)
            throw es;

        if ((es=pPoly->setTextStyle(pTextStyleRecord->objectId()))!=Acad::eOk)
            throw es;
        else
            Fire_Notification(DISPID_TEXTSTYLENAME);
    }
    catch(const Acad::ErrorStatus)
    {
        return Error(L"Failed to set TextStyleName.",IID_IComPolygon,E_FAIL);
    }
    catch(const HRESULT hr)
    {
        return Error(L"Invalid argument.",IID_IComPolygon,hr);
    }
	return S_OK;
}
Esempio n. 16
0
void BlockDraw_ConfigDlg::fillBlockList()
{
    // 清空
    m_blockList.ResetContent();

    // 填充块列表
    AcDbBlockTable* pBlockTable;
    acdbHostApplicationServices()->workingDatabase()
    ->getSymbolTable( pBlockTable, AcDb::kForRead );

    // Iterate through the block table and disaply the names in the list box.
    AcString name;
    AcDbBlockTableIterator* pBTItr;
    if ( pBlockTable->newIterator( pBTItr ) == Acad::eOk )
    {
        while ( !pBTItr->done() )
        {
            AcDbBlockTableRecord* pRecord;
            if ( pBTItr->getRecord( pRecord, AcDb::kForRead ) == Acad::eOk )
            {
                pRecord->getName( name );
                // 排除默认的2个块定义(模型空间和图纸空间)
                if( name.find( ACDB_MODEL_SPACE ) < 0 && name.find( ACDB_PAPER_SPACE ) < 0 )
                {
                    m_blockList.AddString( name.kACharPtr() );
                }
                pRecord->close();
            }
            pBTItr->step();
        }
    }
    pBlockTable->close();
}
Esempio n. 17
0
bool Additional_Class::FindLayer( CString LaylerName )
{
	int n = 0;//判断是否找到图层
	//////////////////////////////////////////////////////////////////////////
	AcDbLayerTable *pLayerTbl;
	acdbHostApplicationServices()->workingDatabase()
		->getSymbolTable(pLayerTbl, AcDb::kForWrite);

	// 建立图层遍历器
	AcDbLayerTableIterator *pLayerIterator;
	pLayerTbl->newIterator(pLayerIterator);
	//
	AcDbLayerTableRecord *pLayerTableRcd;
	ACHAR *pLtName;
	ACHAR *pLtNameTT;
	CString pLtNameStr;
	for (; !pLayerIterator->done(); pLayerIterator->step()) 
	{
		pLayerIterator->getRecord(pLayerTableRcd, AcDb::kForWrite);
		pLayerTableRcd->getName(pLtName);
		pLayerTableRcd->close();
		pLtNameStr = pLtName;
		if (pLtNameStr == LaylerName)
		{
			return true;
		}
		else
		{
			free(pLtName);
		}
	}
	return false;
}
Esempio n. 18
0
AcDbObjectId Additional_Class::Creat_Table(AcGePoint3d TablePoint, vector<CString> Title, double ColWidth, double RowHeight, double TextHeight)
{
	AcDbTable *pTable = new AcDbTable();
	AcDbObjectId TableID;
	pTable->setNumColumns(Title.size());
	pTable->setNumRows(1);
	pTable->setColumnWidth(ColWidth);
	pTable->setRowHeight(RowHeight);
	pTable->setDirection(AcGeVector3d(1,0,0));
	pTable->setNormal(AcGeVector3d(0,0,1));
	
	pTable->setPosition(TablePoint);
	AcDbBlockTable *pBlockTable;
	AcDbBlockTableRecord *pBlockTableRecord;
	acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable, AcDb::kForRead);
	pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);
	pBlockTableRecord->appendAcDbEntity(TableID, pTable);
	//pBlockTable->close();
	pBlockTableRecord->close();
	//pTable->setTextString(0,0, "桩 号");
	//pTable->setTextHeight(0,0,10);
	//pTable->setTextString(0,1, "X坐标值");
	//pTable->setTextHeight(0,1,10);
	//pTable->setTextString(0,2, "Y坐标值");
	//pTable->setTextHeight(0,2,10);
	//pTable->setTextString(0,3, "特性值");
	//pTable->setTextHeight(0,3,10);
	//pTable->setTextString(0,4, "长 度");
	//pTable->setTextHeight(0,4,10);
	pTable->close();
	return TableID;
}
void
ArxDbgUiTdcObjReactorsBase::OnObjAttach() 
{
    CString newHandle, str;
    AcDbObjectId objId;

        // see if specified handle is valid
    m_ebHandle.GetWindowText(newHandle);
    if (ArxDbgUtils::handleStrToObjId(acdbHostApplicationServices()->workingDatabase(),
					newHandle, objId, false) != Acad::eOk) {
        str.Format(_T("\"%s\" is not a valid handle."), newHandle);
        ArxDbgUtils::alertBox(str);
        m_ebHandle.SetSel(0, -1); // reset to select all
        m_ebHandle.SetFocus();
        return;
    }

	AcDbObjectIdArray newObjIds;
	newObjIds.append(objId);

	attachObjReactors(newObjIds);

    m_ebHandle.SetWindowText(_T(""));    // reset edit box to be empty for new handle

	displayObjList();
}
bool insertPoints(std::map<std::wstring,AcGePoint3d>& m_Points, Adesk::Int16 pointStyle, double pointSize, double textHeight)
{
	
	AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
	AcCmColor pointColor;
	AcGePoint3d temp;
	AcDbPoint* tmp_point = nullptr;
	AcDbText* tmp_txt = nullptr;
	AcDbBlockTable* pBT = nullptr;
	AcDbBlockTableRecord* pBTR = nullptr;
	ACHAR* nrPct = nullptr;
	/*****************************************************************/
	pointColor.setColorIndex(7);
	Layer::Create(_T("pctContur"), pointColor, false, false, false);
	Layer::Create(_T("nrPct"), pointColor, false, false, false);
	Acad::ErrorStatus es = Acad::eOk;
	es = acdbHostApplicationServices()->workingDatabase()->setPdmode(pointStyle);
	es = acdbHostApplicationServices()->workingDatabase()->setPdsize(pointSize);

	/*****************************************************************/

	pDb->getSymbolTable(pBT, AcDb::kForRead);
	pBT->getAt(ACDB_MODEL_SPACE, pBTR, AcDb::kForWrite);
	pBT->close();

	std::map<std::wstring, AcGePoint3d>::iterator it;
	for (it = m_Points.begin(); it != m_Points.end();it++)
	{
		const wchar_t* key = it->first.c_str();
		tmp_point = new AcDbPoint;
		tmp_point->setPosition(it->second);
		tmp_point->setLayer(_T("pctContur"));
		
		tmp_txt = new AcDbText(it->second, key, AcDbObjectId::kNull, textHeight, 0);
		tmp_txt->setLayer(_T("nrPct"));
		

		pBTR->appendAcDbEntity(tmp_point);
		pBTR->appendAcDbEntity(tmp_txt);
		tmp_point->close();
		tmp_txt->close();
	}

	pBTR->close();

	return true;
}
Esempio n. 21
0
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();
}
Esempio n. 22
0
  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);

 }
Esempio n. 23
0
AcDbObjectId GetTextStyle(const CString& style)
{
	AcDbTextStyleTable *pTextStyleTbl;
	acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pTextStyleTbl, AcDb::kForWrite);
	AcDbObjectId fontId;
	pTextStyleTbl->getAt(style, fontId);
	pTextStyleTbl->close();

	return fontId;
}
Esempio n. 24
0
void CmdHelper::InitAllData()
{
	//初始化必须数据(建立词典、扩展数据appname等)
	SystemHelper::Start();
	//读取字段
	CString appDir = ArxUtilHelper::GetAppPathDir( _hdllInstance );
	//FieldHelper::InitDataField( ArxUtilHelper::BuildPath( appDir, _T( "Datas\\煤层气抽采-字段-图元属性.txt" ) ) );
	//加载线型
	acdbHostApplicationServices()->workingDatabase()->loadLineTypeFile( _T( "JIS_02_0.7" ), _T( "acadiso.lin" ) );
}
Esempio n. 25
0
	//-------------------------------------------------------------------------------------------
	// 
	//  功能: 向层表中添加记录(创建新层)
	//                 
	//
	//  作者:Qin H.X.
	//
	// 日期:200709
	//
	//  历史:无
	//
	//----------------------------------------------------------------------------------------------
	// - CGDCH03.AddLayer command (do not rename)
	static void CGDCH03AddLayer(void)
	{
		//先声明一个空的层表指针
		AcDbLayerTable *pLayerTbl;  
		//通过当前图形数据库获取层表对象指针
		//打开层表为写入状态
		acdbHostApplicationServices()->workingDatabase()  ->getSymbolTable(pLayerTbl, AcDb::kForWrite); 

		//判断层是否已经存在
		if(!pLayerTbl->has(_T("MyLayer"))) {   
			//新层表记录
			AcDbLayerTableRecord *pLayerTblRcd=  new AcDbLayerTableRecord;
			pLayerTblRcd->setName(_T("MyLayer"));   //设定图层名
			pLayerTblRcd->setIsFrozen(0);   // 图层解冻
			pLayerTblRcd->setIsOff(0);      // 打开图层
			pLayerTblRcd->setVPDFLT(0);   // 使用默认视口
			pLayerTblRcd->setIsLocked(0);   // 图层解锁
			// AcCmColor是ACAD颜色管理类
			AcCmColor color;    
			color.setColorIndex(1);  
			// 图层颜色为红色    
			pLayerTblRcd->setColor(color);  
			// 为给新图层设置线型,要得到线型表记录的ID。
			//  以下的代码演示如何得到并操作记录ID
			AcDbLinetypeTable *pLinetypeTbl;
			AcDbObjectId ltId;
			acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLinetypeTbl, AcDb::kForRead);
			if ((pLinetypeTbl->getAt(_T("DASHED"), ltId))!= Acad::eOk)	{  
				acutPrintf(_T("\n未发现DASHED线型使用CONTINUOUS线型"));
				// 每一个不完全空的图形数据库的线型表中都有线型名为CONTINUOUS 的默认记录
				pLinetypeTbl->getAt(_T("CONTINUOUS"), ltId);
			}
			pLinetypeTbl->close();
			pLayerTblRcd->setLinetypeObjectId(ltId);
			pLayerTbl->add(pLayerTblRcd);
			pLayerTblRcd->close();
			pLayerTbl->close();
		} else {
			pLayerTbl->close();
			acutPrintf(_T("\n层已经存在"));
		}

	}
Esempio n. 26
0
bool ArxDictTool::IsDictExist( const CString& dictName )
{
    AcDbDictionary* pNamedobj;
    acdbHostApplicationServices()->workingDatabase()->getNamedObjectsDictionary( pNamedobj, AcDb::kForRead );

    bool ret = pNamedobj->has( dictName );
    pNamedobj->close();

    return ret;
}
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();
    }
  }
Esempio n. 28
0
// Removes the database reactor
//
void
clearReactors()
{
	AsdkDbReactor *pDbr;
	if ((pDbr = gpAsdkAppDocGlobals->dbReactor()) != NULL)
	{
        acdbHostApplicationServices()->workingDatabase()->removeReactor(pDbr);
        delete pDbr;
        gpAsdkAppDocGlobals->setDbReactor(NULL);
    }
}
Esempio n. 29
0
// Adds a reactor to the database to monitor changes.
// This can be called multiple times without any ill
// effect because subsequent calls will be ignored.
//
void
watchDb()
{
    if (gpDbr == NULL) {
        gpDbr = new AsdkDbReactor();
    }
    acdbHostApplicationServices()->workingDatabase()->addReactor(gpDbr);
    acutPrintf(
        "  Added Database Reactor to "
        "acdbHostApplicationServices()->workingDatabase().\n");
}
Esempio n. 30
-1
AcDbObjectId Additional_Class::Draw_Rectangle( AcGePoint2d stPt, double length, double height )
{
	AcDbPolyline *pPolyline = new AcDbPolyline(4);
	AcGePoint2d stPt1, stPt2, stPt3, stPt4;
	stPt1 = stPt;
	pPolyline->addVertexAt(0, stPt1, 0, 0, 0);
	stPt2.x = stPt.x +length;
	stPt2.y = stPt.y;
	pPolyline->addVertexAt(1, stPt2, 0, 0, 0);
	stPt3.x = stPt2.x;
	stPt3.y = stPt2.y + height;
	pPolyline->addVertexAt(2, stPt3, 0, 0, 0);
	stPt4.x = stPt3.x - length;
	stPt4.y = stPt3.y;
	pPolyline->addVertexAt(3, stPt4, 0, 0, 0);
	pPolyline->setClosed(Adesk::kTrue);
	AcDbBlockTable *pBlockTable = NULL;
	acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable, AcDb::kForRead);
	//this->Open_BlockTable(pBlockTable, NREADMODE);
	AcDbBlockTableRecord *pBlockTableRecord = NULL;
	pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);
	//acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable, AcDb::kForRead);
	//this->Open_ModelTableRecord(pBlockTableRecord, pBlockTable, NWRITEMODE);
	AcDbObjectId TempLineID;
	pBlockTableRecord->appendAcDbEntity(TempLineID, pPolyline);
	pPolyline->close();
	pBlockTable->close();
	pBlockTableRecord->close();
	return TempLineID;
}