EPLAN API 入门系列- 提高篇(How to Add/Remove GraphicalLayer?)

Add GraphicalLayer:

 1  GraphicalLayer oGpl = null;

 2  GraphicalLayerTable layerTable = oPage.Project.LayerTable;

 3 

 4  if (oGpl == null)

 5   {

 6     oGpl = new GraphicalLayer();

 7     MultiLangString description = new MultiLangString();

 8     description.AddString(ISOCode.Language.L___, "Graphic.General");

 9     oGpl.Pen.ColorId = 1;

10     oGpl.Create(layerTable, "Epl" + cnt.ToString(), description);

11    }

12  

13    foreach (GraphicalLayer layer2 in layerTable.Layers)

14    {

15      if (layer2.Name == "Epl0" || layer2.Name == "Epl1")

16      {

17        oGpl = layer2;

18        if (!oGpl.isVisible)

19        {

20          oGpl.isVisible = true;

21        }

22        oGpl.Pen.ColorId = 1;

23        oGpl.Store();

24      }

25     }

Remove GraphicalLayer:

 1   GraphicalLayer layer = null;

 2   GraphicalLayerTable layerTable = currentProject.LayerTable;

 3   GraphicalLayer[] layers = layerTable.Layers;

 4   for (int num = 0; num < layers.Length; num++)

 5   {

 6     GraphicalLayer layer2 = layers[num];

 7     if (layer2.Name == "Epl0" || layer2.Name == "Epl1")

 8     {

 9        layerTable.RemoveLayer(layers[num]);

10     }

11   }

 

 

你可能感兴趣的:(remove)