Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
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);

 }
Ejemplo n.º 3
0
// 現在の状態を覚える
bool CAllLayerState::memorize(AcDbDatabase* pDb)
{
	// レイヤテーブルの取得
	AcDbLayerTable* pLayerTable = NULL;
	if (pDb->getLayerTable(pLayerTable, AcDb::kForRead) != Acad::eOk)
		return false;

	AcDbLayerTableIterator* pIter;
	pLayerTable->newIterator(pIter);
	for (; !pIter->done(); pIter->step()) {
		// レイヤを取得
		AcDbObjectId idLayer;
		pIter->getRecordId(idLayer);
		CLayerState layerstate(idLayer);
		push_back(layerstate);
	}
	delete pIter;

	// 閉じとく
	pLayerTable->close();
	return true;
}