本文整理汇总了C++中AcDbLayerTable::has方法的典型用法代码示例。如果您正苦于以下问题:C++ AcDbLayerTable::has方法的具体用法?C++ AcDbLayerTable::has怎么用?C++ AcDbLayerTable::has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AcDbLayerTable
的用法示例。
在下文中一共展示了AcDbLayerTable::has方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetOneLayer
//把一层设置为OFF or ON
void CArxHelper::SetOneLayer(const TCHAR *name,int flag,bool YN)
//flag 1:isoff 2:isfrozen 3:islocked
{
AcDbLayerTable *pLayerTable;
acdbCurDwg()->getLayerTable(pLayerTable,AcDb::kForRead);
if(!pLayerTable->has(name))
{
pLayerTable->close();
return;
}
AcDbObjectId id;
pLayerTable->getAt(name,id);
AcDbLayerTableRecord *pLayerTableRecord;
acdbOpenObject(pLayerTableRecord,id,AcDb::kForWrite);
switch(flag)
{
case 1:
pLayerTableRecord->setIsOff(YN);
break;
case 2:
pLayerTableRecord->setIsFrozen(YN);
break;
case 3:
pLayerTableRecord->setIsLocked(YN);
break;
}
pLayerTableRecord->close();
pLayerTable->close();
}
示例2: ModifyLayerProp
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();
}
示例3: SetLayerIsOff
void Additional_Class::SetLayerIsOff( CString strLayerName)
{
AcDbLayerTable *pLayTbl = NULL;
acdbCurDwg()->getLayerTable(pLayTbl, AcDb::kForWrite);
if(!pLayTbl->has(strLayerName))
{
pLayTbl->close(); //该图层不存在
return;
}
AcDbLayerTableRecord *pLayTblRec = NULL;
AcDbObjectId objId;
pLayTbl->getAt(strLayerName, pLayTblRec, AcDb::kForWrite);
pLayTbl->close();
//pLayTblRec->isInUse();
if (pLayTblRec==NULL)
{
return;
}
bool tempBool = pLayTblRec->isOff();
if (tempBool == false)
{
pLayTblRec->setIsOff(true);
}
else
{
pLayTblRec->setIsOff(false);
}
pLayTblRec->close();
return;
}
示例4: acdbHostApplicationServices
// This function creates a new AcDbLayerTableRecord, fills
// it in, and adds it to the layer table
//
// THE FOLLOWING CODE APPEARS IN THE SDK DOCUMENT.
//
void
addLayer()
{
AcDbLayerTable *pLayerTbl;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pLayerTbl, AcDb::kForWrite);
if (!pLayerTbl->has(_T("ASDK_TESTLAYER"))) {
AcDbLayerTableRecord *pLayerTblRcd
= new AcDbLayerTableRecord;
pLayerTblRcd->setName(_T("ASDK_TESTLAYER"));
pLayerTblRcd->setIsFrozen(0);// layer to THAWED
pLayerTblRcd->setIsOff(0); // layer to ON
pLayerTblRcd->setVPDFLT(0); // viewport default
pLayerTblRcd->setIsLocked(0);// un-locked
AcCmColor color;
color.setColorIndex(1); // set color to red
pLayerTblRcd->setColor(color);
// For linetype, we need to provide the object ID of
// the linetype record for the linetype we want to
// use. First, we need to get the object ID.
//
AcDbLinetypeTable *pLinetypeTbl;
AcDbObjectId ltId;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pLinetypeTbl, AcDb::kForRead);
if ((pLinetypeTbl->getAt(_T("DASHED"), ltId))
!= Acad::eOk)
{
acutPrintf(_T("\nUnable to find DASHED")
_T(" linetype. Using CONTINUOUS"));
// CONTINUOUS is in every drawing, so use it.
//
pLinetypeTbl->getAt(_T("CONTINUOUS"), ltId);
}
pLinetypeTbl->close();
pLayerTblRcd->setLinetypeObjectId(ltId);
pLayerTbl->add(pLayerTblRcd);
pLayerTblRcd->close();
pLayerTbl->close();
} else {
pLayerTbl->close();
acutPrintf(_T("\nlayer already exists"));
}
}
示例5: CheakLayerExit
static void CheakLayerExit(CString layerName,int colorIndx, AcDb::LineWeight lineWeigt)
{
//int colorIndx = 7; //默认的颜色为白色
//AcDb::LineWeight lineWeigt = AcDb::kLnWt000;
//lineWeigt = AcDb::kLnWt030;
AcDbLayerTable* pLayerTbl = NULL;
// 获取当前的数据库
AcDbDatabase*pDB=acdbHostApplicationServices()->workingDatabase();
// 因为要创建新的图层,所以先要以写的方式获取图层表
pDB->getSymbolTable(pLayerTbl,AcDb::kForWrite);
// 检查图层是否存在
if (!pLayerTbl->has(layerName)) {
// 初始化一个新的对象,并且设置它的属性
AcDbLayerTableRecord *pLayerTblRcd = new AcDbLayerTableRecord;
pLayerTblRcd->setName(layerName);
pLayerTblRcd->setIsFrozen(0); // 图层设置为THAWED(解冻的)
pLayerTblRcd->setIsOff(0); // 图层设置为ON(开着的)
pLayerTblRcd->setIsLocked(0); // 图层 un-locked(解锁的)
AcCmColor color;
color.setColorIndex(colorIndx); // 图层的颜色设置
pLayerTblRcd->setColor(color);
pLayerTblRcd->setLineWeight(lineWeigt);
// 增加一个新的图层到容器(表)中
pLayerTbl->add(pLayerTblRcd);
// 把新建的图层关闭(不要删除它)
pLayerTblRcd->close();
// 关闭容器(表)
pLayerTbl->close();
}
else {
// 如果这个图层已经存在,仅仅需要关闭表继续就是
AcDbLayerTableRecord *pLayerTblRcd;
pLayerTbl->getAt(layerName, pLayerTblRcd, AcDb::kForWrite);
AcCmColor color;
color.setColorIndex(colorIndx); // 图层的颜色设置
pLayerTblRcd->setColor(color);
pLayerTblRcd->setLineWeight(lineWeigt);
pLayerTblRcd->close();
pLayerTbl->close();
//acutPrintf(_T("\nMYLAYER already exists"));
}
}
示例6:
//-------------------------------------------------------------------------------------------
//
// 功能: 向层表中添加记录(创建新层)
//
//
// 作者: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层已经存在"));
}
}
示例7: ASSERT
Acad::ErrorStatus
ArxDbgUtils::addNewLayer(LPCTSTR layerName, AcDbDatabase* db)
{
ASSERT(db != NULL);
// if layer already exists, then just return
AcDbLayerTable* layTbl;
Acad::ErrorStatus es = db->getSymbolTable(layTbl, AcDb::kForRead);
if (es != Acad::eOk)
return es;
if (layTbl->has(layerName)) {
layTbl->close();
return Acad::eOk;
}
// upgrade to write
es = layTbl->upgradeOpen();
if (es != Acad::eOk) {
ASSERT(0);
layTbl->close();
return es;
}
// make sure the name gets set ok
AcDbLayerTableRecord* newRec = new AcDbLayerTableRecord;
es = newRec->setName(layerName);
if (es != Acad::eOk) {
delete newRec;
layTbl->close();
return Acad::eInvalidInput;
}
// look up value for default linetype CONTINUOUS,
// AcDbLayerTableRecord doesn't set this automatically (at least it didn't in Sedona)
newRec->setLinetypeObjectId(db->continuousLinetype());
es = layTbl->add(newRec);
if (es != Acad::eOk)
delete newRec;
else
newRec->close();
layTbl->close();
return es;
}
示例8: OnTvSelChanged
void CLayerTreeDlg::OnTvSelChanged(NMHDR* pNMHDR)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
TV_ITEM tvi = pNMTreeView->itemNew;
HTREEITEM hItem = tvi.hItem;
if(m_tree.ItemHasChildren(hItem))
{
return;
}
CString strLayerName = m_tree.GetItemText(hItem);
Acad::ErrorStatus es = Acad::eOk;
AcDbDatabase* pDB = acdbHostApplicationServices()->workingDatabase();
if (NULL == pDB)
return;
AcDbLayerTable *pLyTable = NULL;
AcDbLayerTableRecord *pLyRcd = NULL;
es = pDB->getSymbolTable(pLyTable,AcDb::kForRead); //获得当前数据库中层表指针
if ( es != Acad::eOk )
{
acutPrintf("\n获取LayerTable的时候发生错误,请稍后再试。\n");
return;
}
if ( !pLyTable->has(strLayerName) )
{
pLyTable->close();
return;
}
pLyTable->close();
SetCurrentLayer(strLayerName);
}
示例9: ShowLayer
void CLayerTreeDlg::ShowLayer(HTREEITEM hItem, BOOL bShow)
{
CString sLayerName = m_tree.GetItemText(hItem);
HTREEITEM hChild = m_tree.GetNextItem(hItem,TVGN_CHILD);
// 只有树叶才有对应的图层
if (hChild == NULL)
{
ShowLayer(sLayerName, bShow);
//如果是面层,还要把它的填充图层打开
CString sHatchLayer;
sHatchLayer.Format("%s_填充",sLayerName);
bool hasHatch = false;
acDocManager->lockDocument(acDocManager->curDocument());
AcDbLayerTable * pLayerTbl = NULL;
Acad::ErrorStatus es =
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTbl,AcDb::kForRead);
if (pLayerTbl->has(sHatchLayer))
{
AcDbLayerTableRecord * pLayerTbRcd = NULL;
es = pLayerTbl->getAt(sHatchLayer,pLayerTbRcd,AcDb::kForWrite);
pLayerTbRcd->setIsOff(bShow == 0);
pLayerTbRcd->close();
hasHatch = true;
}
pLayerTbl->close();
acDocManager->unlockDocument(acDocManager->curDocument());
}
while(hChild != NULL)
{
ShowLayer(hChild, bShow);
hChild = m_tree.GetNextItem(hChild,TVGN_NEXT);
}
}
示例10: ModifyEntityLayer
void ModifyEntityLayer()
{
int nRet = 0;
ads_name entName;
ads_point ptPick;
nRet = acedEntSel(_T("\nSelect an entity to change it's layer:"), entName, ptPick);
if (nRet != RTNORM)
{
acutPrintf(_T("\nFailed to select!"));
return;
}
Acad::ErrorStatus es;
AcDbObjectId objId;
AcDbEntity* pEnt = NULL;
acdbGetObjectId(objId, entName);
es = acdbOpenAcDbEntity(pEnt, objId, AcDb::kForWrite);
if (es != Acad::eOk)
{
acutPrintf(_T("\nFailed to open entity!"));
return;
}
ACHAR szNewName[255];
_tcscpy(szNewName, _T("NewLayer"));
bool bHasDone = false;
AcDbDatabase* pCurDb = acdbHostApplicationServices()->workingDatabase();
if (pCurDb == NULL)
{
acutPrintf(_T("\nError:Current database is NULL!"));
return;
}
AcDbObjectId layerId;
AcDbLayerTable* pLayerTbl = NULL;
es = pCurDb->getLayerTable(pLayerTbl, AcDb::kForRead);
if (es == Acad::eOk)
{
if (pLayerTbl->has(szNewName))
{
es = pLayerTbl->getAt(szNewName, layerId);
if (es == Acad::eOk)
{
es = pEnt->setLayer(layerId);
if (es == Acad::eOk)
{
bHasDone = true;
}
}
}
pLayerTbl->close();
}
pEnt->close();
if (bHasDone)
{
acutPrintf(_T("\nThe layer of entity has modified to layer:\"%s\""), szNewName);
}
else
{
acutPrintf(_T("\nFailed to modify the layer of entity to layer:\"%s\""), szNewName);
}
}
示例11: Get_LayerLW
bool Additional_Class::Get_LayerLW( CString LayerName, double &Length, double &Width )
{
AcDbLayerTable *pLayerTbl = NULL;
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTbl,AcDb::kForRead);
if (!pLayerTbl->has(LayerName))
{
//acutPrintf("\n木有%s层!", LayerName);
//SetError("THERE ISN`T"+LayerName+"LATYER!", "Get_LayerLW");
pLayerTbl->close();
return false;
}
AcDbObjectId layerId;
pLayerTbl->getAt(LayerName, layerId);
pLayerTbl->close();
AcDbBlockTable *pBlkTbl = NULL;
////获得当前数据库块表
acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlkTbl,AcDb::kForWrite);
////获得模型空间块表记录
AcDbBlockTableRecord *pBlkTblRcd = NULL;
pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForRead);
pBlkTbl->close();
////创建块表记录遍历器
AcDbBlockTableRecordIterator *pltr;
pBlkTblRcd->newIterator(pltr);
AcDbEntity *pEnt;
//AcDbEntityPointer pEnt_Ptr;
////AcDbObjectPointer<AcDbPolyline> pPolyLine_Ptr;
AcDbPolyline *pPolyLine = NULL;
AcDbObjectIdArray PolyLineID_List;
for (pltr->start(); !pltr->done(); pltr->step())
{
pltr->getEntity(pEnt, AcDb::kForRead);
// //pEnt_Ptr.acquire(pEnt);
if (pEnt->layerId()==layerId)
{
if (pEnt->isKindOf(AcDbPolyline::desc()))
{
pPolyLine = AcDbPolyline::cast(pEnt);
if (pPolyLine != NULL)
{
if (PolyLineIfRectangle(pPolyLine)==true)
{
PolyLineID_List.append(pPolyLine->objectId());
}
}
}
}
}
if (PolyLineID_List.length() >1)
{
acutPrintf(_T("Bom Error 1002\n"));// 有很多矩形
delete pltr;
pEnt->close();
pPolyLine->close();
pBlkTblRcd->close();
return false;
}
////pPolyLine.open(PolyLineID_List[0], AcDb::kForRead);
acdbOpenAcDbEntity(pEnt,PolyLineID_List[0], AcDb::kForRead); //error!
pPolyLine = AcDbPolyline::cast(pEnt);
Get_RectangleLW(pPolyLine, Length, Width);
pBlkTblRcd->close();
pPolyLine->close();
pEnt->close();
delete pltr;
return true;
}
示例12: LaylerFilter
bool Additional_Class::LaylerFilter( CString LaylerName, AcDbObjectIdArray &EntityID_Array, bool(*Filter)(AcDbEntity*, AcDbObjectId&) )
{
AcDbLayerTable *pLayerTbl;
acdbHostApplicationServices()->workingDatabase()->getLayerTable(pLayerTbl,AcDb::kForWrite);
if (false == (pLayerTbl->has(LaylerName)))
{
//acutPrintf("\n木有%s层!", LaylerName);
//SetError("THERE ISTN`T"+LaylerName+"LAYER!", "LaylerFilter");
pLayerTbl->close();
return false;
}
AcDbObjectId layerId;
pLayerTbl->getAt(LaylerName,layerId);
AcDbBlockTable *pBlkTbl;
//获得当前数据库块表
acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlkTbl,AcDb::kForWrite);
//获得模型空间块表记录
AcDbBlockTableRecord *pBlkTblRcd;
pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForWrite);
//创建块表记录遍历器
AcDbBlockTableRecordIterator *pltr;
pBlkTblRcd->newIterator(pltr);
AcDbEntity *pEnt;
AcDbObjectId temp_layerId;
AcDbObjectId entityID;
//pBlkTblRcd->close();
//pBlkTbl->close();
//pLayerTbl->close();
for (pltr->start(); !pltr->done(); pltr->step())
{
if(Acad::eOk ==pltr->getEntity(pEnt, AcDb::kForRead, false))
{
//if (200>Check_Entity(pEnt)>=100)
//{
temp_layerId = pEnt->layerId();
if (temp_layerId == layerId) // 在当前图层中
{
entityID = pEnt->objectId();
if (Filter(pEnt, entityID) == true) // 符合过滤条件
{
EntityID_Array.append(entityID);
}
}
//}
pEnt->close();
}
}
int Len = EntityID_Array.length();
if (Len == 0)
{
pBlkTbl->close();
pLayerTbl->close();
pBlkTblRcd->close();
return false;
}
pBlkTbl->close();
pLayerTbl->close();
pBlkTblRcd->close();
return true;
}
示例13: OnCreateLine
void CMyDlg::OnCreateLine()
{
// TODO: Add your control notification handler code here
acDocManager->lockDocument(curDoc());
int i;
int m, n;
char *buf = (char*)malloc(20);
AcDbObjectId LineId;
AcDbLine *pLine = NULL;
//块表
AcDbBlockTable *pTb = NULL;
//块表记录
AcDbBlockTableRecord *pTbr = NULL;
//层表
AcDbLayerTable *pLyr = NULL;
//层表记录
AcDbLayerTableRecord* pLyrr = NULL;
//图形数据库
AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase();
Acad::ErrorStatus es;
CListCtrl *pListCtr = (CListCtrl *)GetDlgItem( IDC_LIST1 );
//设置随机数种子
srand(time(NULL));
//更新数据
UpdateData(TRUE);
m_VecSize += m_Edit5;
m_xVec.resize(m_VecSize);
m_yVec.resize(m_VecSize);
//acutPrintf("%d\n", m_Edit1);
es = pDb->getLayerTable(pLyr, AcDb::kForWrite); //以写的方式打开层表
es = pDb->getBlockTable(pTb, AcDb::kForRead); //以读的方式打开块表
es = pTb->getAt(ACDB_MODEL_SPACE, pTbr, AcDb::kForWrite);//以写的方式打开块表记录
//创建图层GalLineTest
if (!pLyr->has("GalLineTest"))
{
pLyrr = new AcDbLayerTableRecord; //创建层记录
pLyrr->setName("GalLineTest"); //设置名字
//pLyrr->setColor(color); //设置颜色
//pLyrr->setLineWeight(lnWt); //设置线宽
if (Acad::eOk != pLyr->add(pLyrr)) //添加该层记录到层表
{
//添加失败
delete pLyrr; //释放内存
pLyr->close(); //关闭层表
}
//关闭层表记录
pLyrr->close();
}
//关闭层表
pLyr->close();
//生成点坐标
for (i = 0; i < m_Edit5; ++i)
{
if ((m_Edit2 != 0) && (m_Edit4 != 0))
{
m_xVec[i] = rand() % m_Edit2 + m_Edit1;
m_yVec[i] = rand() % m_Edit4 + m_Edit3;
}
else
{
m_xVec[i] = 0;
m_yVec[i] = 0;
}
}
//遍历点坐标
for (m = 0; m < m_Edit5; ++m)
{
for (n = (m+1); n < m_Edit5; ++n)
{
if ((m_xVec[m] != m_xVec[n]) && (m_yVec[m] != m_yVec[n]))
{
AcGePoint3d ptStart(m_xVec[m], m_yVec[m], 0);
AcGePoint3d ptEnd(m_xVec[n], m_yVec[n], 0);
pLine = new AcDbLine(ptStart, ptEnd);
//pLine->setColor();
pLine->setLayer("GalLineTest");
//创建线段
es = pTbr->appendAcDbEntity(LineId, pLine);
if (Acad::eOk == es)
{
++m_lLineCnt;
}
//acutPrintf("%d\n", LineId);
sprintf(buf, "%d", LineId);
m_ListCtr.InsertItem(m_Row, buf);
//.........这里部分代码省略.........
示例14: CreateLayer
void CreateLayer()
{
Acad::ErrorStatus es;
ACHAR szNewName[255];
_tcscpy(szNewName, _T("NewLayer"));
AcDbDatabase* pCurDb = acdbHostApplicationServices()->workingDatabase();
if (pCurDb == NULL)
{
acutPrintf(_T("\nError:Current database is NULL!"));
return;
}
AcDbLayerTableRecord* pNewLayer = new AcDbLayerTableRecord;
es = pNewLayer->setName(szNewName);
if (es != Acad::eOk)
{
acutPrintf(_T("\nFailed setName of the layer!"));
delete pNewLayer;
return;
}
AcCmColor cmColor;
cmColor.setColorIndex(1);
pNewLayer->setColor(cmColor);
pNewLayer->setIsFrozen(false);
pNewLayer->setIsOff(false);
pNewLayer->setVPDFLT(false);
pNewLayer->setIsLocked(false);
bool bStat = false;
AcDbLayerTable* pLayerTbl = NULL;
es = pCurDb->getLayerTable(pLayerTbl, AcDb::kForWrite);
if (es == Acad::eOk)
{
if (pLayerTbl->has(szNewName))
{
acutPrintf(_T("\nThe Layer \"%s\" has existed!"), szNewName);
delete pNewLayer;
}
else
{
es = pLayerTbl->add(pNewLayer);
if (es == Acad::eOk)
{
bStat = true;
pNewLayer->close();
}
else
{
acutPrintf(_T("\nFailed to add a new layer in LayerTable!"));
delete pNewLayer;
}
}
pLayerTbl->close();
}
if (bStat)
{
acutPrintf(_T("\nCreated the new layer: \"%s\" successfully!"), szNewName);
}
else
{
acutPrintf(_T("\nFailed to create the layer: \"%s\""), szNewName);
}
}
示例15: DelLayer
void DelLayer()
{
ACHAR szNewName[256];
_tcscpy(szNewName, _T("NewLayer"));
AcDbDatabase* pCurDb = acdbHostApplicationServices()->workingDatabase();
if (pCurDb == NULL)
{
acutPrintf(_T("\nError:Current database is NULL!"));
return;
}
bool bHas = false;
bool bDeled = false;
Acad::ErrorStatus es;
AcDbObjectId layerId;
AcDbLayerTable* pLayerTbl = NULL;
es = pCurDb->getLayerTable(pLayerTbl, AcDb::kForRead);
if (es == Acad::eOk)
{
if (pLayerTbl->has(szNewName))
{
AcDbLayerTableRecord* pLayerTblRcd = NULL;
AcDbLayerTableIterator* pLTblIter = NULL;
pLayerTbl->newIterator(pLTblIter);
for (pLTblIter->start(); !pLTblIter->done(); pLTblIter->step())
{
ACHAR* szLayerName = NULL;
pLTblIter->getRecord(pLayerTblRcd, AcDb::kForWrite, true);
if (pLayerTblRcd)
{
pLayerTblRcd->getName(szLayerName);
if (_tcscmp(szNewName, szLayerName) == 0)
{
es = pLayerTblRcd->erase(true);
if (es == Acad::eOk)
{
bDeled = true;
}
}
if (szLayerName)
{
ads_free(szLayerName);
}
pLayerTblRcd->close();
}
}
if (pLTblIter)
{
delete pLTblIter;
pLTblIter = NULL;
}
}
pLayerTbl->close();
}
if (bDeled)
{
acutPrintf(_T("\nErased the layer: \"%s\" successfully!"), szNewName);
}
else
{
acutPrintf(_T("\nFailed to erase the layer: \"%s\""), szNewName);
}
}