<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Create Layer and Line C# in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190146#M16963</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/537692"&gt;@k005&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;got you&lt;/P&gt;</description>
    <pubDate>Fri, 26 Mar 2021 18:15:29 GMT</pubDate>
    <dc:creator>essam-salah</dc:creator>
    <dc:date>2021-03-26T18:15:29Z</dc:date>
    <item>
      <title>Create Layer and Line C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10189577#M16954</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a command that draws Line by Layer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sample:&lt;BR /&gt;Layer name: Grobeton&lt;BR /&gt;Layer Color: 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;osnap : Intersection,MidPoint,EndPoint&amp;nbsp; = will be marked&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I will draw a line that will be active with this layer ... How can I do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 15:04:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10189577#M16954</guid>
      <dc:creator>k005</dc:creator>
      <dc:date>2021-03-26T15:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layer and Line C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10189874#M16955</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/537692"&gt;@k005&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so you want to draw a line in a specific layer? and give it a specific color ?&lt;/P&gt;&lt;P&gt;and you want to programmatically activate 2D Object Snaps:&amp;nbsp;&lt;SPAN&gt;Intersection, MidPoint, EndPoint?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 16:48:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10189874#M16955</guid>
      <dc:creator>essam-salah</dc:creator>
      <dc:date>2021-03-26T16:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layer and Line C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10189893#M16956</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3650456"&gt;@essam-salah&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes that's right&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 16:51:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10189893#M16956</guid>
      <dc:creator>k005</dc:creator>
      <dc:date>2021-03-26T16:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layer and Line C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10189933#M16957</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/537692"&gt;@k005&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so why you don't do it manually: set the current layer to the layer you want and OSnap you want?&lt;/P&gt;&lt;P&gt;what is the point?&lt;/P&gt;&lt;P&gt;give example please&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 17:07:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10189933#M16957</guid>
      <dc:creator>essam-salah</dc:creator>
      <dc:date>2021-03-26T17:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layer and Line C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10189941#M16958</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for example :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll go over an existing drawing. and this will be on the layer I want. osnap, on the other hand, is just to activate object&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;capture for the moment. it is ok even if it is not ..&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 17:10:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10189941#M16958</guid>
      <dc:creator>k005</dc:creator>
      <dc:date>2021-03-26T17:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layer and Line C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190009#M16959</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/537692"&gt;@k005&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;not clear actually,&lt;/P&gt;&lt;P&gt;so try to give a real example with:&lt;/P&gt;&lt;P&gt;INPUT: ...&lt;/P&gt;&lt;P&gt;OUPUT: ...&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 17:34:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190009#M16959</guid>
      <dc:creator>essam-salah</dc:creator>
      <dc:date>2021-03-26T17:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layer and Line C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190012#M16960</link>
      <description>or screen shot</description>
      <pubDate>Fri, 26 Mar 2021 17:35:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190012#M16960</guid>
      <dc:creator>essam-salah</dc:creator>
      <dc:date>2021-03-26T17:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layer and Line C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190074#M16961</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3650456"&gt;@essam-salah&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't think screen recording is needed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just want to do this: create a layer that does not exist in the dwg file (give it color) and draw a line with it. so much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;osnap automatically catches the point I mentioned, better if it is activated.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 17:56:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190074#M16961</guid>
      <dc:creator>k005</dc:creator>
      <dc:date>2021-03-26T17:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layer and Line C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190079#M16962</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3650456"&gt;@essam-salah&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even if the layer is present, it doesn't matter. let it occur again. according to the color I set&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 17:57:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190079#M16962</guid>
      <dc:creator>k005</dc:creator>
      <dc:date>2021-03-26T17:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layer and Line C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190146#M16963</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/537692"&gt;@k005&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;got you&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 18:15:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190146#M16963</guid>
      <dc:creator>essam-salah</dc:creator>
      <dc:date>2021-03-26T18:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layer and Line C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190261#M16964</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/537692"&gt;@k005&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try this:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;using aApp = Autodesk.AutoCAD.ApplicationServices;&lt;/LI-CODE&gt;&lt;LI-CODE lang="general"&gt;[CommandMethod("cieCreateLayer")]
        public static void CreateLayer()
        {
            var doc = aApp.Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var editor = doc.Editor;

            // ask user for layer name
            var promptResult = editor.GetString("Layer Name:");
            if (promptResult.Status != PromptStatus.OK)
            {
                editor.WriteMessage("\nNo String Found\n");
                return;
            }
            string layerName = promptResult.StringResult;

            // set osnap
            aApp.Application.SetSystemVariable("OSMODE", 32); // Intersection
            aApp.Application.SetSystemVariable("OSMODE", 2); // Mid Point
            aApp.Application.SetSystemVariable("OSMODE", 1); // End Point

            using (var ts = db.TransactionManager.StartTransaction())
            {
                // get layers table
                var layersTable = (LayerTable)ts.GetObject(db.LayerTableId, OpenMode.ForWrite);

                // create layer if not exist
                if (layersTable.Has(layerName) == false)
                {
                    var newLayer = new LayerTableRecord();
                    newLayer.Name = layerName;

                    layersTable.Add(newLayer);
                    ts.AddNewlyCreatedDBObject(newLayer, true);
                }

                // set color
                var layer = (LayerTableRecord)layersTable[layerName].GetObject(OpenMode.ForWrite);
                layer.Color = Color.FromRgb(255, 0, 0);
                // set current layer
                db.Clayer = layer.Id;

                // commit changes
                ts.Commit();
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 18:54:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190261#M16964</guid>
      <dc:creator>essam-salah</dc:creator>
      <dc:date>2021-03-26T18:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layer and Line C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190274#M16965</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/537692"&gt;@k005&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;just replace the osnap 3 lines with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;// set osnap
aApp.Application.SetSystemVariable("OSMODE", 32 | 2 | 1); // Intersection, Mid Point, End Point&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;just discovered&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Autodesk.AutoCAD.EditorInput.ObjectSnapMasks&lt;/EM&gt;&lt;/STRONG&gt; is a flags&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 19:04:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190274#M16965</guid>
      <dc:creator>essam-salah</dc:creator>
      <dc:date>2021-03-26T19:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layer and Line C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190384#M16966</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3650456"&gt;@essam-salah&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so far...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;only the command will not exit and the &lt;U&gt;LINE&lt;/U&gt; command will run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And it shouldn't ask for the layer name. It should be fixed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So we will enter the layer names in C # code&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 20:27:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190384#M16966</guid>
      <dc:creator>k005</dc:creator>
      <dc:date>2021-03-26T20:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layer and Line C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190429#M16967</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/537692"&gt;@k005&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;[CommandMethod("cieCreateLayer")]
        public static void CreateLayer()
        {
            var doc = aApp.Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var editor = doc.Editor;

            string layerName = "Grobeton";

            // set osnap
            aApp.Application.SetSystemVariable("OSMODE", 32 | 2 | 1); // Intersection, Mid Point, End Point            

            using (var ts = db.TransactionManager.StartTransaction())
            {
                // get layers table
                var layersTable = (LayerTable)ts.GetObject(db.LayerTableId, OpenMode.ForWrite);

                // create layer if not exist
                if (layersTable.Has(layerName) == false)
                {
                    var newLayer = new LayerTableRecord();
                    newLayer.Name = layerName;

                    layersTable.Add(newLayer);
                    ts.AddNewlyCreatedDBObject(newLayer, true);
                }

                // set color
                var layer = (LayerTableRecord)layersTable[layerName].GetObject(OpenMode.ForWrite);
                layer.Color = Color.FromRgb(255, 0, 0);
                // set current layer
                db.Clayer = layer.Id;

                // commit changes
                ts.Commit();
            }

            // send Line Cmd
            doc.SendStringToExecute("MULTIPLE LINE ", true, false, false);

        }&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 26 Mar 2021 20:22:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190429#M16967</guid>
      <dc:creator>essam-salah</dc:creator>
      <dc:date>2021-03-26T20:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layer and Line C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190453#M16968</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/537692"&gt;@k005&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;have you tried the last code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 20:30:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190453#M16968</guid>
      <dc:creator>essam-salah</dc:creator>
      <dc:date>2021-03-26T20:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layer and Line C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190455#M16969</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/537692"&gt;@k005&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[CommandMethod("cieCreateLayer")]
        public static void CreateLayer()
        {
            var doc = aApp.Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var editor = doc.Editor;

            string layerName = "Grobeton";

            // set osnap
            aApp.Application.SetSystemVariable("OSMODE", 32 | 2 | 1); // Intersection, Mid Point, End Point            

            using (var ts = db.TransactionManager.StartTransaction())
            {
                // get layers table
                var layersTable = (LayerTable)ts.GetObject(db.LayerTableId, OpenMode.ForWrite);

                // create layer if not exist
                if (layersTable.Has(layerName) == false)
                {
                    var newLayer = new LayerTableRecord();
                    newLayer.Name = layerName;

                    layersTable.Add(newLayer);
                    ts.AddNewlyCreatedDBObject(newLayer, true);
                }

                // set color
                var layer = (LayerTableRecord)layersTable[layerName].GetObject(OpenMode.ForWrite);
                layer.Color = Color.FromRgb(255, 0, 0);
                // set current layer
                db.Clayer = layer.Id;

                // commit changes
                ts.Commit();
            }

            // send Line Cmd
            doc.SendStringToExecute("MULTIPLE LINE ", true, false, false);
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 20:32:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190455#M16969</guid>
      <dc:creator>essam-salah</dc:creator>
      <dc:date>2021-03-26T20:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Create Layer and Line C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190500#M16970</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3650456"&gt;@essam-salah&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much. &lt;span class="lia-unicode-emoji" title=":hugging_face:"&gt;🤗&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will add a screenshot or a file in my next questions. &lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 20:48:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-layer-and-line-c/m-p/10190500#M16970</guid>
      <dc:creator>k005</dc:creator>
      <dc:date>2021-03-26T20:48:23Z</dc:date>
    </item>
  </channel>
</rss>

