<?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: Copy layer from another DWG in c# in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/copy-layer-from-another-dwg-in-c/m-p/11169710#M12884</link>
    <description>&lt;P&gt;The code will vary depending if the source drawing is open in AutoCAD or not.&lt;BR /&gt;Will the user have a choice of the source drawing ? or will the source be constant ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Judicious use of Google should provide several possible solutions.&lt;/P&gt;</description>
    <pubDate>Sun, 15 May 2022 07:02:46 GMT</pubDate>
    <dc:creator>kerry_w_brown</dc:creator>
    <dc:date>2022-05-15T07:02:46Z</dc:date>
    <item>
      <title>Copy layer from another DWG in c#</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-layer-from-another-dwg-in-c/m-p/11169671#M12883</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good day. I'm searching a code to copy a layer from dwg to current. I did some testing code from the net and I was not able to figure it out the right solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please share working code on copying a layer either vb or C#&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 May 2022 05:46:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-layer-from-another-dwg-in-c/m-p/11169671#M12883</guid>
      <dc:creator>alexisgacia</dc:creator>
      <dc:date>2022-05-15T05:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: Copy layer from another DWG in c#</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-layer-from-another-dwg-in-c/m-p/11169710#M12884</link>
      <description>&lt;P&gt;The code will vary depending if the source drawing is open in AutoCAD or not.&lt;BR /&gt;Will the user have a choice of the source drawing ? or will the source be constant ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Judicious use of Google should provide several possible solutions.&lt;/P&gt;</description>
      <pubDate>Sun, 15 May 2022 07:02:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-layer-from-another-dwg-in-c/m-p/11169710#M12884</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2022-05-15T07:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: Copy layer from another DWG in c#</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-layer-from-another-dwg-in-c/m-p/11171045#M12885</link>
      <description>&lt;P&gt;The path is a constant.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The function looks like below, but I wasn't able to figure out to properly copy the layer to the current drawing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;public boolean GetLayerFromLib(LayerName as string)&amp;nbsp;
{
string dwgPath =&amp;nbsp;@"c:\test.dwg";

'open dwgPath database
'read the LayerTable
'Check if has the LayerName
'if exist copy to current database and return true
'else return false

}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2022 10:34:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-layer-from-another-dwg-in-c/m-p/11171045#M12885</guid>
      <dc:creator>alexisgacia</dc:creator>
      <dc:date>2022-05-16T10:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Copy layer from another DWG in c#</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-layer-from-another-dwg-in-c/m-p/11172311#M12886</link>
      <description>&lt;P&gt;Here's an example:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        public bool GetLayerFromLib(string layerName)
        {
            var curDb = HostApplicationServices.WorkingDatabase;
            string dwgPath = @"c:\test.dwg";
            using (var db = new Database(false, true))
            {
                db.ReadDwgFile(dwgPath, FileOpenMode.OpenForReadAndAllShare, true, null);
                using (var tr = db.TransactionManager.StartOpenCloseTransaction())
                {
                    var layerTable = (LayerTable)tr.GetObject(db.LayerTableId, OpenMode.ForRead);
                    if (!layerTable.Has(layerName))
                        return false;
                    var ids = new ObjectIdCollection();
                    ids.Add(layerTable[layerName]);
                    var mapping = new IdMapping();
                    db.WblockCloneObjects(ids, curDb.LayerTableId, mapping, DuplicateRecordCloning.Replace, false);
                    return true;
                }
            }
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 16 May 2022 15:51:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-layer-from-another-dwg-in-c/m-p/11172311#M12886</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2022-05-16T15:51:04Z</dc:date>
    </item>
    <item>
      <title>Re: Copy layer from another DWG in c#</title>
      <link>https://forums.autodesk.com/t5/net-forum/copy-layer-from-another-dwg-in-c/m-p/11174126#M12887</link>
      <description>It works!&lt;BR /&gt;Thank you very much.</description>
      <pubDate>Tue, 17 May 2022 10:51:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/copy-layer-from-another-dwg-in-c/m-p/11174126#M12887</guid>
      <dc:creator>alexisgacia</dc:creator>
      <dc:date>2022-05-17T10:51:56Z</dc:date>
    </item>
  </channel>
</rss>

