<?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 Apply layer modification to be able to select them in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/apply-layer-modification-to-be-able-to-select-them/m-p/8907963#M21830</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is probably one of the most ridiculous questions I will ever ask, but I have to do it...&lt;/P&gt;&lt;P&gt;Once I have opened a transaction I am trying to unfreeze a specific layer and then in the same transaction be able to select it. Is this possible or am i required to open one transaction, apply the change and then open another to select the layer? My code (in part) is as follows.&lt;/P&gt;&lt;PRE&gt;Using tr As Transaction = doc.TransactionManager.StartTransaction()
                Dim bt As BlockTable = CType(tr.GetObject(db.BlockTableId, OpenMode.ForWrite), BlockTable)
                Dim btr As BlockTableRecord = CType(tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
                Dim lt As LayerTable = tr.GetObject(db.LayerTableId, OpenMode.ForRead)

                ' Turn on the cabling layer just in case
                If lt.Has("Cabling") Then
                    Dim ltr As New LayerTableRecord()
                    ltr.Name = "Cabling"
                    lt.UpgradeOpen()
                    ltr.IsFrozen = False
                Else
                    ed.WriteMessage(vbLf &amp;amp; "No cabling exists...")
                    Return
                End If

                Dim psr As PromptSelectionResult = ed.GetSelection(New SelectionFilter(tv1))
                If (psr.Status &amp;lt;&amp;gt; PromptStatus.OK) Then
                    Return
                End If&lt;/PRE&gt;&lt;P&gt;I am not able to find a way to commit the layer change and then be able to select it. the layer change does not take effect and hence I am left with the program jumping out on the return.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have some advice that may help me to understand what i am doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Sat, 13 Jul 2019 23:32:22 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-07-13T23:32:22Z</dc:date>
    <item>
      <title>Apply layer modification to be able to select them</title>
      <link>https://forums.autodesk.com/t5/net-forum/apply-layer-modification-to-be-able-to-select-them/m-p/8907963#M21830</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is probably one of the most ridiculous questions I will ever ask, but I have to do it...&lt;/P&gt;&lt;P&gt;Once I have opened a transaction I am trying to unfreeze a specific layer and then in the same transaction be able to select it. Is this possible or am i required to open one transaction, apply the change and then open another to select the layer? My code (in part) is as follows.&lt;/P&gt;&lt;PRE&gt;Using tr As Transaction = doc.TransactionManager.StartTransaction()
                Dim bt As BlockTable = CType(tr.GetObject(db.BlockTableId, OpenMode.ForWrite), BlockTable)
                Dim btr As BlockTableRecord = CType(tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
                Dim lt As LayerTable = tr.GetObject(db.LayerTableId, OpenMode.ForRead)

                ' Turn on the cabling layer just in case
                If lt.Has("Cabling") Then
                    Dim ltr As New LayerTableRecord()
                    ltr.Name = "Cabling"
                    lt.UpgradeOpen()
                    ltr.IsFrozen = False
                Else
                    ed.WriteMessage(vbLf &amp;amp; "No cabling exists...")
                    Return
                End If

                Dim psr As PromptSelectionResult = ed.GetSelection(New SelectionFilter(tv1))
                If (psr.Status &amp;lt;&amp;gt; PromptStatus.OK) Then
                    Return
                End If&lt;/PRE&gt;&lt;P&gt;I am not able to find a way to commit the layer change and then be able to select it. the layer change does not take effect and hence I am left with the program jumping out on the return.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have some advice that may help me to understand what i am doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jul 2019 23:32:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/apply-layer-modification-to-be-able-to-select-them/m-p/8907963#M21830</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-13T23:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: Apply layer modification to be able to select them</title>
      <link>https://forums.autodesk.com/t5/net-forum/apply-layer-modification-to-be-able-to-select-them/m-p/8907984#M21831</link>
      <description>&lt;P&gt;It seems to me you are not commiting changes to the layer table record.&lt;/P&gt;&lt;P&gt;You seem to be unnecessarily making a new layer, which baffles me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a look here for the basics&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://docs.autodesk.com/ACD/2011/ESP/filesMDG/WS1a9193826455f5ff2566ffd511ff6f8c7ca-3d1c.htm" target="_blank" rel="noopener"&gt;http://docs.autodesk.com/ACD/2011/ESP/filesMDG/WS1a9193826455f5ff2566ffd511ff6f8c7ca-3d1c.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;added:&lt;/P&gt;&lt;P&gt;In fact, I can't see a LayerTable record in your code.&lt;/P&gt;&lt;P&gt;For your future sanity use a name something like mSpace in place of btr.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't do VB so I won't say more.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jul 2019 00:18:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/apply-layer-modification-to-be-able-to-select-them/m-p/8907984#M21831</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2019-07-14T00:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: Apply layer modification to be able to select them</title>
      <link>https://forums.autodesk.com/t5/net-forum/apply-layer-modification-to-be-able-to-select-them/m-p/8908000#M21832</link>
      <description>&lt;P&gt;This is a more recent reference&lt;/P&gt;&lt;P&gt;&lt;A href="https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-NET/files/GUID-4ADF80DD-5BEF-4C28-90A9-76FDA8E2E804-htm.html" target="_blank"&gt;https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-NET/files/GUID-4ADF80DD-5BEF-4C28-90A9-76FDA8E2E804-htm.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I'm wondering:&lt;/P&gt;&lt;P&gt;If the layer does not exist why are you creating it and making a selection set using an empty layer ??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jul 2019 00:55:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/apply-layer-modification-to-be-able-to-select-them/m-p/8908000#M21832</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2019-07-14T00:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: Apply layer modification to be able to select them</title>
      <link>https://forums.autodesk.com/t5/net-forum/apply-layer-modification-to-be-able-to-select-them/m-p/8908054#M21833</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;@Anonymous&amp;nbsp;,&lt;/P&gt;&lt;P&gt;This seems to work OK for me.&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.theswamp.org/index.php?topic=55320.0" target="_blank"&gt;http://www.theswamp.org/index.php?topic=55320.0&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's C# but you should be able to decipher it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code may be revised when it is reviewed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jul 2019 04:25:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/apply-layer-modification-to-be-able-to-select-them/m-p/8908054#M21833</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2019-07-14T04:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Apply layer modification to be able to select them</title>
      <link>https://forums.autodesk.com/t5/net-forum/apply-layer-modification-to-be-able-to-select-them/m-p/8908116#M21834</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To be able to commit the 'thaw layer' stuff, you have to use a separated transaction.&lt;/P&gt;
&lt;P&gt;It could be a nested one, but I think it's not a good practice to start a transaction if it may not be used.&lt;/P&gt;
&lt;P&gt;In this case, I'd only start a the main transaction if the PromptSemectionResult.Status is OK.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an example of how this can be done:&lt;/P&gt;
&lt;PRE&gt;            // thaw the layer if exists
            // as none user interaction can occur during theis process, we use an OpenCloseTransaction which is cheaper
            using (var tr = new OpenCloseTransaction())
            {
                var layerTable = (LayerTable)tr.GetObject(db.LayerTableId, OpenMode.ForRead);
                if (layerTable.Has("Cabling"))
                {
                    var layer = (LayerTableRecord)tr.GetObject(layerTable["Cabling"], OpenMode.ForRead);
                    if (layer.IsFrozen)
                    {
                        layer.UpgradeOpen();
                        layer.IsFrozen = false;
                    }
                }
                tr.Commit();
            }

            // build a selection filter and prompt the user for the selection
            var filter = new SelectionFilter(new[] { new TypedValue(8, "Cabling") });
            var selection = ed.GetSelection(filter);
            if (selection.Status != PromptStatus.OK) return;

            // we only start the main transaction if some entities have been selected
            using (var tr = db.TransactionManager.StartTransaction())
            {
                var modelSpace = (BlockTableRecord)tr.GetObject(
                    SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);

                // do your stuff

                tr.Commit();
            }&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 Jul 2019 07:29:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/apply-layer-modification-to-be-able-to-select-them/m-p/8908116#M21834</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2019-07-14T07:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Apply layer modification to be able to select them</title>
      <link>https://forums.autodesk.com/t5/net-forum/apply-layer-modification-to-be-able-to-select-them/m-p/8908588#M21835</link>
      <description>&lt;P&gt;Thank you both for responding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had suspected this was the case, but wanted to make sure from people far more skilled than I.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BH&lt;/P&gt;</description>
      <pubDate>Sun, 14 Jul 2019 21:39:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/apply-layer-modification-to-be-able-to-select-them/m-p/8908588#M21835</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-07-14T21:39:24Z</dc:date>
    </item>
  </channel>
</rss>

