- UID
- 270071
- 积分
- 94
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-5-31
- 最后登录
- 1970-1-1
|
发表于 2005-12-18 18:54:25
|
显示全部楼层
void createNewLayer(char* lyrname)
{
// We need to check if the layer name exists
// If the layer name exists, apply the color
// linetype id and whither to make it current
// or not. In order to be current it cannot be
// frozen, so we need to check for this also.
// If the layer name does not exist we just create
// a new layer with the properties contained in the arguments
AcDbLayerTable *pLyrTable;
AcDbLayerTableRecord *pLyrTblRecord;
AcDbObjectId recId;
AcDbDatabase *pCurDb = NULL;
pCurDb = acdbHostApplicationServices()->workingDatabase();
pCurDb->getLayerTable(pLyrTable, AcDb::kForRead);
// Check to see if the layer name exists
if(pLyrTable->has(lyrname))
{
pLyrTable->getAt(lyrname, pLyrTblRecord, AcDb::kForWrite, Adesk::kFalse);
// pLyrTblRecord now points at the layer table record
// which was opened for write
pLyrTblRecord->setIsFrozen(Adesk::kFalse);
// pLyrTblRecord->setLinetypeObjectId(ltypeId);
}
else
{
// Note how we can change the open mode
// of the layer table from AcDb::kForRead
// to AcDb::kForWrite
pLyrTable->upgradeOpen();
pLyrTblRecord = new AcDbLayerTableRecord;
pLyrTblRecord->setName(lyrname);
pLyrTable->add(pLyrTblRecord);
}
// Get the layer Table ObjectId
recId = pLyrTblRecord->objectId();
pLyrTblRecord->close();
pLyrTable->close();
} |
|