<?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 a new layer (C#) in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390089#M72538</link>
    <description>Hi joel,&lt;BR /&gt;
&lt;BR /&gt;
Which clearly didn't work on your first post.&lt;BR /&gt;
&lt;BR /&gt;
Try&lt;BR /&gt;
&lt;BR /&gt;
&lt;CODE&gt;&lt;BR /&gt;
Put your code here.&lt;BR /&gt;
This has always worked for me&lt;BR /&gt;
&lt;/CODE&gt;&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Laurie Comerford&lt;BR /&gt;
&lt;BR /&gt;
joelkarr wrote:&lt;BR /&gt;
&amp;gt; by the way....I read a sticky at the main page of the forum and learned &lt;BR /&gt;
&amp;gt; that to keep it in code format you use: \{code} code here \{code} Edited &lt;BR /&gt;
&amp;gt; by: joelkarr on Dec 1, 2008 11:32 PM</description>
    <pubDate>Tue, 02 Dec 2008 00:06:29 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2008-12-02T00:06:29Z</dc:date>
    <item>
      <title>Create a new layer (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390087#M72536</link>
      <description>Ok...I thought I would make a new thread and see what you guys thought.....&lt;BR /&gt;
&lt;BR /&gt;
I would like to add the ability to make the layer a plot layer or a no plot layer but am not sure whether that is a boolean for PlotStyle property or what?&lt;BR /&gt;
&lt;BR /&gt;
I am taking all the parameters from a Access database so we can just assume the parameters below are correct.&lt;BR /&gt;
&lt;BR /&gt;
Any other suggestions or thoughts?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
public void createLayer(string layerName, int layerColor, string layerLineType, string layerDescription)&lt;BR /&gt;
        {&lt;BR /&gt;
            Document doc = Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;
            &lt;BR /&gt;
            Database db = doc.Database;&lt;BR /&gt;
            //start transaction&lt;BR /&gt;
            using (Transaction tr = db.TransactionManager.StartTransaction())&lt;BR /&gt;
            {&lt;BR /&gt;
&lt;BR /&gt;
                try&lt;BR /&gt;
                {&lt;BR /&gt;
                   &lt;BR /&gt;
                    //Get current layerTable&lt;BR /&gt;
                    LayerTable lt = (LayerTable)tr.GetObject(db.LayerTableId, OpenMode.ForWrite);&lt;BR /&gt;
                    &lt;BR /&gt;
                    //Make new layTable record &lt;BR /&gt;
                    LayerTableRecord ltr = new LayerTableRecord();&lt;BR /&gt;
&lt;BR /&gt;
                    //Set Layer Properties&lt;BR /&gt;
                    ltr.Name = layerName;&lt;BR /&gt;
                    &lt;BR /&gt;
                    //LayerColor value is being sent in as a int32 to converting to int32 fo byACi colorMethod.  I am using numbers such as 251 and 5 as colors.&lt;BR /&gt;
                    Int16 layerColorShort = Convert.ToInt16(layerColor); &lt;BR /&gt;
                    ltr.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci, layerColorShort);&lt;BR /&gt;
                    ltr.Description = layerDescription;&lt;BR /&gt;
&lt;BR /&gt;
                    // get linetypeId....do line types always have the same id...for example is Continuous always the same id?&lt;BR /&gt;
                    LinetypeTable lt2 = (LinetypeTable)tr.GetObject(db.LinetypeTableId, OpenMode.ForRead);&lt;BR /&gt;
                    foreach (ObjectId lineid in lt2)&lt;BR /&gt;
                    {&lt;BR /&gt;
                        LinetypeTableRecord ltr2 = (LinetypeTableRecord)tr.GetObject(lineid, OpenMode.ForRead);&lt;BR /&gt;
                        if (ltr2.Name == layerLineType)&lt;BR /&gt;
                        {&lt;BR /&gt;
&lt;BR /&gt;
                            ltr.LinetypeObjectId = ltr2.Id;&lt;BR /&gt;
                        }&lt;BR /&gt;
                    }&lt;BR /&gt;
                    //add newly created layer back to layerTable&lt;BR /&gt;
                    lt.Add(ltr);&lt;BR /&gt;
                    tr.AddNewlyCreatedDBObject(ltr, true);&lt;BR /&gt;
                    tr.Commit();&lt;BR /&gt;
&lt;BR /&gt;
                }&lt;BR /&gt;
&lt;BR /&gt;
                catch&lt;BR /&gt;
                {&lt;BR /&gt;
&lt;BR /&gt;
                    tr.Abort();&lt;BR /&gt;
&lt;BR /&gt;
                }&lt;BR /&gt;
            }&lt;BR /&gt;
{code}</description>
      <pubDate>Mon, 01 Dec 2008 23:31:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390087#M72536</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-12-01T23:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new layer (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390088#M72537</link>
      <description>by the way....I read a sticky at the main page of the forum and learned that to keep it in code format you use:&lt;BR /&gt;
&lt;BR /&gt;
\{code}&lt;BR /&gt;
code here&lt;BR /&gt;
\{code}

Edited by: joelkarr on Dec 1, 2008 11:32 PM</description>
      <pubDate>Mon, 01 Dec 2008 23:31:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390088#M72537</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-12-01T23:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new layer (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390089#M72538</link>
      <description>Hi joel,&lt;BR /&gt;
&lt;BR /&gt;
Which clearly didn't work on your first post.&lt;BR /&gt;
&lt;BR /&gt;
Try&lt;BR /&gt;
&lt;BR /&gt;
&lt;CODE&gt;&lt;BR /&gt;
Put your code here.&lt;BR /&gt;
This has always worked for me&lt;BR /&gt;
&lt;/CODE&gt;&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Laurie Comerford&lt;BR /&gt;
&lt;BR /&gt;
joelkarr wrote:&lt;BR /&gt;
&amp;gt; by the way....I read a sticky at the main page of the forum and learned &lt;BR /&gt;
&amp;gt; that to keep it in code format you use: \{code} code here \{code} Edited &lt;BR /&gt;
&amp;gt; by: joelkarr on Dec 1, 2008 11:32 PM</description>
      <pubDate>Tue, 02 Dec 2008 00:06:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390089#M72538</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-12-02T00:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new layer (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390090#M72539</link>
      <description>&lt;DIV id="jive-html-wrapper-div"&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2"&gt;Laurie doesn't understand that the \{code} tags preserve the &lt;BR /&gt;
formatting of code when viewed via the web interface.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2"&gt;Unfortuantely, for those of us who want no part of the &lt;BR /&gt;
stinking, dysfunctional pile of garbage web interface, code formatting is not &lt;BR /&gt;
preserved in newsreaders.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;FONT size="2"&gt;If you want the benefit of&amp;nbsp;more of your peers, my advice &lt;BR /&gt;
would be to switch to a newsreader for accessing the newsgroups.&lt;/FONT&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;BR /&gt;-- &lt;BR /&gt;&lt;BR /&gt;&lt;A&gt;&lt;BR /&gt;
href="http://www.caddzone.com"&amp;gt;http://www.caddzone.com&lt;/A&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;AcadXTabs: MDI Document Tabs for AutoCAD 2009&lt;BR /&gt;Supporting AutoCAD 2000 &lt;BR /&gt;
through 2009&lt;BR /&gt;&lt;A&gt;&lt;BR /&gt;
href="http://www.acadxtabs.com"&amp;gt;http://www.acadxtabs.com&lt;/A&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;Introducing AcadXTabs 2010:&lt;BR /&gt;&lt;A&gt;&lt;BR /&gt;
href="http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm"&amp;gt;http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm&lt;/A&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;BR /&gt;
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"&amp;gt;&lt;BR /&gt;
  &lt;DIV&gt;&amp;lt;joelkarr&amp;gt; wrote in message &lt;A&gt;&lt;BR /&gt;
  href="news:6081982@discussion.autodesk.com"&amp;gt;news:6081982@discussion.autodesk.com&lt;/A&gt;...&lt;/DIV&gt;by &lt;BR /&gt;
  the way....I read a sticky at the main page of the forum and learned that to &lt;BR /&gt;
  keep it in code format you use: \{code} code here \{code} Edited by: joelkarr &lt;BR /&gt;
  on Dec 1, 2008 11:32 PM&lt;/BLOCKQUOTE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 02 Dec 2008 00:33:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390090#M72539</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-12-02T00:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new layer (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390091#M72540</link>
      <description>You use LayerTableRecord.IsPlottable - Simple Read/Write Boolean property.</description>
      <pubDate>Tue, 02 Dec 2008 02:16:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390091#M72540</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2008-12-02T02:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new layer (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390092#M72541</link>
      <description>thanks chief.  I plan on having more code to come so hopefully it can at least serve as a starting point for new .net autocad developers.&lt;BR /&gt;
&lt;BR /&gt;
And its always nice to have someone else check my code and make suggestions haha.&lt;BR /&gt;
&lt;BR /&gt;
Next on the list is removing a set of layers but prompting the user to move any objects to the 0 layer if they exist on a layer to be deleted.</description>
      <pubDate>Tue, 02 Dec 2008 14:57:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390092#M72541</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-12-02T14:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new layer (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390093#M72542</link>
      <description>Do you want to prompt them, or just automatically move the items yourself?  I can see value in both.  If you prompt them, then we can assume that anything left over is to be marked for deletion.  &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Either way your going to have to cycle through all entities in the block table looking for anything that happens to have that layer as its property in order to change/erase the enitity before you remove the layer.  (even though the layer will still exist if you only mark it for erase)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Would be nice if a layer can tell you what entities are using it...  Any ideas out there?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;jvj</description>
      <pubDate>Tue, 02 Dec 2008 15:12:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390093#M72542</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-12-02T15:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new layer (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390094#M72543</link>
      <description>I was thinking to prompt them to either A. Do not  remove layers with objects on them or B. move objects to 0 layer and remove layers&lt;BR /&gt;
&lt;BR /&gt;
Here's a start from Kean Wamsley at http://through-the-interface.typepad.com&lt;BR /&gt;
&lt;BR /&gt;
{code}&lt;BR /&gt;
private static ObjectIdCollection&lt;BR /&gt;
&lt;BR /&gt;
      GetEntitiesOnLayer(string layerName)&lt;BR /&gt;
&lt;BR /&gt;
    {&lt;BR /&gt;
&lt;BR /&gt;
      Document doc =&lt;BR /&gt;
&lt;BR /&gt;
        Application.DocumentManager.MdiActiveDocument;&lt;BR /&gt;
&lt;BR /&gt;
      Editor ed = doc.Editor;&lt;BR /&gt;
&lt;BR /&gt;
      // Build a filter list so that only entities&lt;BR /&gt;
&lt;BR /&gt;
      // on the specified layer are selected&lt;BR /&gt;
&lt;BR /&gt;
      TypedValue[] tvs =&lt;BR /&gt;
&lt;BR /&gt;
        new TypedValue[1] {&lt;BR /&gt;
&lt;BR /&gt;
            new TypedValue(&lt;BR /&gt;
&lt;BR /&gt;
              (int)DxfCode.LayerName,&lt;BR /&gt;
&lt;BR /&gt;
              layerName&lt;BR /&gt;
&lt;BR /&gt;
            )&lt;BR /&gt;
&lt;BR /&gt;
          };&lt;BR /&gt;
&lt;BR /&gt;
      SelectionFilter sf =&lt;BR /&gt;
&lt;BR /&gt;
        new SelectionFilter(tvs);&lt;BR /&gt;
&lt;BR /&gt;
      PromptSelectionResult psr =&lt;BR /&gt;
&lt;BR /&gt;
        ed.SelectAll(sf);&lt;BR /&gt;
&lt;BR /&gt;
      if (psr.Status == PromptStatus.OK)&lt;BR /&gt;
&lt;BR /&gt;
        return&lt;BR /&gt;
&lt;BR /&gt;
          new ObjectIdCollection(&lt;BR /&gt;
&lt;BR /&gt;
            psr.Value.GetObjectIds()&lt;BR /&gt;
&lt;BR /&gt;
          );&lt;BR /&gt;
&lt;BR /&gt;
      else&lt;BR /&gt;
&lt;BR /&gt;
        return new ObjectIdCollection();&lt;BR /&gt;
&lt;BR /&gt;
    }&lt;BR /&gt;
{code}

Edited by: joelkarr on Dec 2, 2008 3:49 PM</description>
      <pubDate>Tue, 02 Dec 2008 15:48:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390094#M72543</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-12-02T15:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Create a new layer (C#)</title>
      <link>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390095#M72544</link>
      <description>Hi Tony,&lt;BR /&gt;
&lt;BR /&gt;
The fact that "\{code}" tags work on the Web interface is irrelevant. &lt;BR /&gt;
They don't work anywhere else and that is sufficient reason to criticise &lt;BR /&gt;
them.  It's not OK to use them and expect all users who want to help are &lt;BR /&gt;
going to be able to see posted code properly formatted.&lt;BR /&gt;
&lt;BR /&gt;
The whole newsgroup situation is absolutely pathetic and the newsgroup &lt;BR /&gt;
manager should be sacked for absolute incompetence.&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Laurie Comerford&lt;BR /&gt;
&lt;BR /&gt;
Tony Tanzillo wrote:&lt;BR /&gt;
&amp;gt; Laurie doesn't understand that the \{code} tags preserve the formatting &lt;BR /&gt;
&amp;gt; of code when viewed via the web interface.&lt;BR /&gt;
&amp;gt;  &lt;BR /&gt;
&amp;gt; Unfortuantely, for those of us who want no part of the stinking, &lt;BR /&gt;
&amp;gt; dysfunctional pile of garbage web interface, code formatting is not &lt;BR /&gt;
&amp;gt; preserved in newsreaders.&lt;BR /&gt;
&amp;gt;  &lt;BR /&gt;
&amp;gt; If you want the benefit of more of your peers, my advice would be to &lt;BR /&gt;
&amp;gt; switch to a newsreader for accessing the newsgroups.&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; -- &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; http://www.caddzone.com&lt;BR /&gt;
&amp;gt;  &lt;BR /&gt;
&amp;gt; AcadXTabs: MDI Document Tabs for AutoCAD 2009&lt;BR /&gt;
&amp;gt; Supporting AutoCAD 2000 through 2009&lt;BR /&gt;
&amp;gt; http://www.acadxtabs.com&lt;BR /&gt;
&amp;gt;  &lt;BR /&gt;
&amp;gt; Introducing AcadXTabs 2010:&lt;BR /&gt;
&amp;gt; http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm&lt;BR /&gt;
&amp;gt;  &lt;BR /&gt;
&amp;gt;  &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt;     &lt;JOELKARR&gt; wrote in message news:6081982@discussion.autodesk.com...&lt;BR /&gt;
&amp;gt;     by the way....I read a sticky at the main page of the forum and&lt;BR /&gt;
&amp;gt;     learned that to keep it in code format you use: \{code} code here&lt;BR /&gt;
&amp;gt;     \{code} Edited by: joelkarr on Dec 1, 2008 11:32 PM&lt;BR /&gt;
&amp;gt;&lt;/JOELKARR&gt;</description>
      <pubDate>Tue, 02 Dec 2008 20:50:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/create-a-new-layer-c/m-p/2390095#M72544</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-12-02T20:50:33Z</dc:date>
    </item>
  </channel>
</rss>

