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


C++ AcDbLayerTableRecord::id方法代码示例

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


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

示例1: SetLayer

AcDbObjectId CArxHelper::SetLayer(TCHAR* layerName)
{
	AcDbObjectId layerId = NULL;
	AcDbLayerTable *pLayerTbl;
	acdbCurDwg()->getLayerTable(pLayerTbl,AcDb::kForWrite);

	AcDbLayerTableIterator *pItr;
	pLayerTbl->newIterator(pItr);

	for(;!pItr->done();pItr->step())
	{
		AcDbLayerTableRecord *pLayer;
		pItr->getRecord(pLayer,AcDb::kForRead);

		TCHAR *str=NULL;
		pLayer->getName(str);
		if(_tcscmp(layerName,str)==0)
			layerId=pLayer->id();
		if(str!=NULL) delete []str;

		pLayer->close();

		if(layerId!=NULL)
			break;
	}

	delete pItr;
	pItr = NULL;

	if(layerId==NULL)
	{
		AcDbLayerTableRecord *pLayerTblRcd=new AcDbLayerTableRecord();
		Acad::ErrorStatus es = pLayerTblRcd->setName(layerName);
		if (es != Acad::eOk)
			pLayerTblRcd->setName(_T("0"));

		pLayerTbl->add(layerId,pLayerTblRcd);

		pLayerTblRcd->close();
	}

	pLayerTbl->close();

	acdbCurDwg() ->setClayer(layerId);

	return layerId;
}
开发者ID:ninuo,项目名称:ArxWorkspace,代码行数:47,代码来源:ArxHelper2.cpp

示例2: SetCurLayler

void Additional_Class::SetCurLayler( CString LaylerName )
{
	AcDbDatabase *pCurDb = NULL;
	pCurDb = acdbHostApplicationServices()->workingDatabase();
	/*pCurDb->setClayer()*/

	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)
		{
			pCurDb->setClayer(pLayerTableRcd->id());
			free(pLtName);
			n = 1;//如果图层找到,则将n赋值为1
			delete pLayerIterator;
			pLayerTbl->close();
			return;
		}
		else
		{
			free(pLtName);
		}
	}

	if (n == 0)
	{
		// 新建图层
		AcDbLayerTableRecord *pLayerTableRecordTT = new AcDbLayerTableRecord;
		pLayerTableRecordTT->setName(LaylerName);
		AcDbObjectId pLayerId;
		pLayerTbl->add(pLayerId, pLayerTableRecordTT);
		pLayerTableRecordTT->getName(pLtNameTT);
		pLayerTableRecordTT->close();
		//struct resbuf pResult;
		//::acedGetVar(_T("CLAYER"),&pResult);//取得当前图层
		//char *p = (LPSTR)(LPCTSTR)LaylerName;
		//pResult.resval.rstring = pLtNameTT;
		//int s=acedSetVar(_T("CLAYER"), &pResult);//将输入的图层设为当前层
		//相当于命令 CLAYER LAYERNAME
		//acutPrintf(_T("\nLinetype name is:  %s"), pResult.resval.rstring);
		//acutPrintf(_T("\nLinetype name is:  %d"), s);
		
		n = 1;//如果图层找到,则将n赋值为1
		delete pLayerIterator;
		pLayerTbl->close();
		struct resbuf pResults;
		::acedGetVar(_T("CLAYER"),&pResults);//取得当前图层
		//pLtNameTT = "0";
		pResults.resval.rstring = pLtNameTT;
		::acedSetVar(_T("CLAYER"), &pResults);//将输入的图层设为当前层
		free(pLtNameTT);
	}
	
	// acutPrintf(_T("\nLinetype name"));
	// acutPrintf(_T("\nLinetype name is:  %s"), pResult.resval.rstring);
}
开发者ID:TobeGodman,项目名称:AutoTrader,代码行数:74,代码来源:Additional_Class.cpp


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