Layer Create Method two variable

Layer Create Method two variable

k005
Advisor Advisor
599 Views
1 Reply
Message 1 of 2

Layer Create Method two variable

k005
Advisor
Advisor

Hello guys;

I want to create a method. In the form of layername1 and layername2. The colors may be the same.

When I call this method from another routine; layername1 and layername2 should be available.

how can I do that ?

I solved the problem with this code now. But it didn't seem like the right format to me... though I used it in code. How can I create a method?

 string layerName = "deneme";
            string layerName2 = "deneme2";
            string rgbTxt = "160,253,129";

 

 

 

//layer oluşturmak başlangıç
                var layersTable = (LayerTable)tr.GetObject(db.LayerTableId, OpenMode.ForWrite);

                // create layer if not exist
                if (layersTable.Has(layerName) == false)
                {
                    var newLayer = new LayerTableRecord();
                    var newLayer2 = new LayerTableRecord();
                    newLayer.Name = layerName;
                    newLayer2.Name = layerName2;
                    layersTable.Add(newLayer);
                    layersTable.Add(newLayer2);
                    tr.AddNewlyCreatedDBObject(newLayer, true);
                    tr.AddNewlyCreatedDBObject(newLayer2, true);

                }
                      


                // set color
                var layer = (LayerTableRecord)layersTable[layerName].GetObject(OpenMode.ForWrite);
                var layer2 = (LayerTableRecord)layersTable[layerName2].GetObject(OpenMode.ForWrite);
                var rgbArr = rgbTxt.Split(',').Select(byte.Parse).ToArray(); // unhandled exception in byte.Parse()
                layer.Color = Color.FromRgb(rgbArr[0], rgbArr[1], rgbArr[2]);
                // set current layer
                //db.Clayer = layer.Id;
                ///// bitiş ///

 

 

0 Likes
Accepted solutions (1)
600 Views
1 Reply
Reply (1)
Message 2 of 2

k005
Advisor
Advisor
Accepted solution

 

 

****** THIS ISSUE IS SOLVED. ********

0 Likes