<?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: change any Entity layer in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/change-any-entity-layer/m-p/8209568#M24969</link>
    <description>&lt;P&gt;Your request is not very clear.&lt;/P&gt;
&lt;P&gt;You should post what you've written so far.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use the WBlockCloneObjects() with a BlockReference instance, you'll import also all symbolTableRecord instances (Layer, Linetype, etc.) linked to the block reference.&lt;/P&gt;</description>
    <pubDate>Sun, 19 Aug 2018 15:18:29 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2018-08-19T15:18:29Z</dc:date>
    <item>
      <title>change any Entity layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/change-any-entity-layer/m-p/8209515#M24966</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to Create a Function called ChangeLayer&lt;/P&gt;&lt;PRE&gt;public void ChangeLayer (Entity ent, string layerName)
{
// Here can i change layer 
}&lt;/PRE&gt;&lt;P&gt;for any entity (Line, PLine, BlockReference, circle, .... )&lt;/P&gt;</description>
      <pubDate>Sun, 19 Aug 2018 14:24:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/change-any-entity-layer/m-p/8209515#M24966</guid>
      <dc:creator>Amremad</dc:creator>
      <dc:date>2018-08-19T14:24:24Z</dc:date>
    </item>
    <item>
      <title>Re: change any Entity layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/change-any-entity-layer/m-p/8209519#M24967</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What's wrong with simply doing:&lt;/P&gt;
&lt;PRE&gt;ent.Layer = layerName;&lt;/PRE&gt;</description>
      <pubDate>Sun, 19 Aug 2018 14:29:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/change-any-entity-layer/m-p/8209519#M24967</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-08-19T14:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: change any Entity layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/change-any-entity-layer/m-p/8209543#M24968</link>
      <description>&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; sorry i missed&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i meant how can i read the layer of block when i insert it from other drawing,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i mean i need to insert the block from other dwg with the same it's layer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and can i use clone directly form other drawing to current ?? something like copy between drawings&lt;/P&gt;</description>
      <pubDate>Sun, 19 Aug 2018 14:52:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/change-any-entity-layer/m-p/8209543#M24968</guid>
      <dc:creator>Amremad</dc:creator>
      <dc:date>2018-08-19T14:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: change any Entity layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/change-any-entity-layer/m-p/8209568#M24969</link>
      <description>&lt;P&gt;Your request is not very clear.&lt;/P&gt;
&lt;P&gt;You should post what you've written so far.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use the WBlockCloneObjects() with a BlockReference instance, you'll import also all symbolTableRecord instances (Layer, Linetype, etc.) linked to the block reference.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Aug 2018 15:18:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/change-any-entity-layer/m-p/8209568#M24969</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-08-19T15:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: change any Entity layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/change-any-entity-layer/m-p/8209623#M24970</link>
      <description>&lt;P&gt;sorry about my english&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have Drawing 'A" has a block which is name "blk" and it;s layer is "my Layer" with color "1"&lt;/P&gt;&lt;P&gt;now iam opening Drawing "B" , i need to insert "blk" in drawing "B" with the same it's layer "my layer"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i hope now you understand me&lt;/P&gt;</description>
      <pubDate>Sun, 19 Aug 2018 16:23:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/change-any-entity-layer/m-p/8209623#M24970</guid>
      <dc:creator>Amremad</dc:creator>
      <dc:date>2018-08-19T16:23:15Z</dc:date>
    </item>
    <item>
      <title>Re: change any Entity layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/change-any-entity-layer/m-p/8209637#M24971</link>
      <description>&lt;P&gt;What's confusing is the world "block" which may mean BlockReference or BlockTableRecord.&lt;/P&gt;
&lt;P&gt;As you say: "&lt;EM&gt;a block which is name "blk" and it;s layer is "my Layer"&lt;/EM&gt; " I suppose you're talking about a block reference (a BlockTableRecord, aka block definition, does not 'have' a Layer).&lt;/P&gt;
&lt;P&gt;As said upper, if you 'WBlockClone' (i.e. deep cloning) a block reference, you also clone the Layer the block reference is inserted on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a little example:&lt;/P&gt;
&lt;PRE&gt;        private static ObjectId ImportBlockReference(Database targetDb, string fileName, string blockName)
        {
            using (var sourceDb = new Database(false, true))
            {
                sourceDb.ReadDwgFile(fileName, FileOpenMode.OpenForReadAndAllShare, false, null);
                using (var tr = sourceDb.TransactionManager.StartOpenCloseTransaction())
                {
                    var ms = (BlockTableRecord)tr.GetObject(
                        SymbolUtilityServices.GetBlockModelSpaceId(sourceDb), OpenMode.ForRead);
                    ObjectId brId = ObjectId.Null;
                    foreach (ObjectId id in ms)
                    {
                        if (id.ObjectClass.DxfName == "INSERT")
                        {
                            var br = (BlockReference)tr.GetObject(id, OpenMode.ForRead);
                            if (br.Name == blockName)
                                brId = id;
                        }
                    }
                    if (!brId.IsNull)
                    {
                        var ids = new ObjectIdCollection();
                        ids.Add(brId);
                        var targetId = SymbolUtilityServices.GetBlockModelSpaceId(targetDb);
                        var mapping = new IdMapping();
                        sourceDb.WblockCloneObjects(ids, targetId, mapping, DuplicateRecordCloning.Ignore, false);
                        if (mapping[brId].IsCloned)
                            return mapping[brId].Value;
                    }
                }
                return ObjectId.Null;
            }
        }&lt;/PRE&gt;
&lt;P&gt;Running:&lt;/P&gt;
&lt;PRE&gt;var id = ImportBlockReference(databaseOfDrawingB, @"A.dwg", "blk");&lt;/PRE&gt;
&lt;P&gt;Will return the ObjectId of the cloned block reference in drawing B if a reference of "blk" have been found in drawing "A" model space.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Aug 2018 16:50:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/change-any-entity-layer/m-p/8209637#M24971</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-08-19T16:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: change any Entity layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/change-any-entity-layer/m-p/8209800#M24972</link>
      <description>&lt;P&gt;yes that what i need exactly &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Aug 2018 20:30:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/change-any-entity-layer/m-p/8209800#M24972</guid>
      <dc:creator>Amremad</dc:creator>
      <dc:date>2018-08-19T20:30:15Z</dc:date>
    </item>
  </channel>
</rss>

