- UID
- 59465
- 积分
- 267
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2003-6-18
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2003-7-9 11:29:25
|
显示全部楼层
- [FONT=courier new]
- AcDbObjectId CCyzConfig::GetLayerId(UINT nLayerIndex)
- {
- AcDbLayerTable* pTable;
- Acad::ErrorStatus es;
- es=acdbCurDwg()->getLayerTable(pTable,AcDb::kForWrite);
- if (es!= Acad::eOk)
- {
- return AcDbObjectId::kNull;
- }
- int i = nLayerIndex;
- AcDbLayerTableRecord *pRecord;
- char LayerAlias[128];
- char LayerName[128];
- UINT color;
- char LineName[128];
- if(!GetLayerInfo(nLayerIndex,LayerAlias,LayerName,&color,LineName))
- {
- if(pTable)
- pTable->close();
- return AcDbObjectId::kNull;
- }
- if(pTable->has(LayerName))
- {
- //这个层已经有了按s_LayerInfo中的值设置
- Acad::ErrorStatus Status;
- Status = pTable->getAt(LayerName, pRecord,AcDb::kForWrite);
- pTable->close();
- if(Status != Acad::eOk)
- {
- return AcDbObjectId::kNull;
- }
- pRecord->setIsFrozen(Adesk::kFalse); //解冻
- pRecord->setIsLocked(Adesk::kFalse); //解锁
- pRecord->setIsOff(Adesk::kFalse); //on
- pRecord->close();
- }
- else //这个层没有,按s_LayerInfo中的值设置
- {
- pRecord = new AcDbLayerTableRecord();
- ASSERT(pRecord != NULL);
- pRecord->setName(LayerName);
- AcCmColor ByLayerColor,LayerColor;
- LayerColor.setColorIndex(color);
- pRecord->setColor(LayerColor);
- AcDbObjectId LineTypeID;
- if(LoadLineType (LineName)) //装入线型成功,否则采用缺省的线型
- {
-
- LineTypeID = GetObjectId(__CYZ_CHECKTABLE_LINETYPE,LineName);
- if(LineTypeID == AcDbObjectId::kNull)
- {
- pTable->close();
- if(pRecord)
- delete pRecord;
- return AcDbObjectId::kNull;
- }
- pRecord->setLinetypeObjectId(LineTypeID);
- }
- pTable->add(pRecord);
- pRecord->close();
- pTable->close();
- ByLayerColor.setColorIndex(256); // bylayer
- acdbCurDwg()->setCecolor(ByLayerColor);
- AcDbObjectId BylayerLineTypeID;
- LineTypeID = GetObjectId(__CYZ_CHECKTABLE_LINETYPE,"BYLAYER");
- VERIFY(LineTypeID != NULL);
- acdbCurDwg()->setCeltype(LineTypeID);
- }
- if(acdbCurDwg()->getLayerTable(pTable,AcDb::kForRead) != Acad::eOk)
- return AcDbObjectId::kNull;
- AcDbObjectId objId;
- pTable->getAt(LayerName, objId);
- pTable->close();
- return objId;
- }
复制代码 |
|