|
[code]void CreateNewLayer()
{
CString sLayerName = _T("NewCreate");
AcDbLayerTable* pLayerTbl = NULL;
if (Acad::eOk == acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTbl, AcDb::kForWrite))
{
if (!pLayerTbl->has(sLayerName))
{
AcDbLayerTableRecord* pLayerRec = new AcDbLayerTableRecord;
if (Acad::eOk == pLayerTbl->add(pLayerRec)) //请注意,一定要先添加到层表和数据库当中,然后才能设置透明度、说明等参数
{
pLayerRec->setName(sLayerName);
pLayerRec->setIsFrozen(0); // layer to THAWED
pLayerRec->setIsOff(0); // layer to ON
pLayerRec->setVPDFLT(0); // viewport default
pLayerRec->setIsLocked(0); // un-locked
AcCmTransparency trans; // 设置透明度
trans.setAlpha(50);
pLayerRec->setTransparency(trans);
AcCmColor cColor; // 设置颜色
cColor.setRGB(255, 0, 0);
pLayerRec->setColor(cColor);
pLayerRec->setDescription(_T("这是一个新创建的图层")); //设置说明
pLayerRec->close();
}
else
delete pLayerRec;
}
pLayerTbl->close();
}
}
[/code] |
|