天天看点

ARX创建新图层,设置颜色,并置为当前图层

// 判断是否存在名称为“LAY”的图层
    AcDbLayerTable *pLayerTbl;
    //获取当前图形层表
    acdbHostApplicationServices()->workingDatabase()->getLayerTable(pLayerTbl, AcDb::kForWrite);
    if (pLayerTbl->has(_T("LAY")))
    {
        pLayerTbl->close();
        return;
    }
    acutPrintf(_T("\n当前图形中未包含\"LAY\"图层!"));
    AcDbLayerTableRecord *pLayerTblRcd = new AcDbLayerTableRecord();
    pLayerTblRcd->setName(_T("LAY"));
    AcDbObjectId layerTblRcdId;
    pLayerTbl->add(layerTblRcdId, pLayerTblRcd);

    AcCmColor color;//设置图层颜色
    color.setColorIndex();
    pLayerTblRcd->setColor(color);
    // 将新建的层表记录添加到层表中
    pLayerTblRcd->close();
    pLayerTbl->close();
    acdbHostApplicationServices()->workingDatabase()->setClayer(layerTblRcdId);//设为当前图层
           

继续阅读