<?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: Is LAYISO available via the API? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/5927499#M37820</link>
    <description>&lt;P&gt;Sitting here watching football I thought about what I would do for this. The following is what I came up with.&lt;/P&gt;
&lt;PRE&gt;using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using System;
using System.Collections.Generic;

namespace Misc_Commands.LayerTools
{
    public class NewLayIso
    {
        [CommandMethod("LayIsoThruCode")]
        public void layisothrucode()
        {
            List&amp;lt;string&amp;gt; layers = new List&amp;lt;string&amp;gt; { "C-ANNO", "C-ROAD" };
            IsolateLayers(layers);
        }

        [CommandMethod ("LayUnIsoThruCode")]
        public void unisothrucode()
        {
            UnisolateLayers();
        }

        private Dictionary&amp;lt;ObjectId, LayInfo&amp;gt; layerColl = null;

        /// &amp;lt;summary&amp;gt;
        /// Isolates a list of layer names
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="layerstoisolate"&amp;gt;Must be passed as a list of layer names using all UPPERCASE letters&amp;lt;/param&amp;gt;
        public void IsolateLayers(List&amp;lt;string&amp;gt; layerstoisolate)
        {
            if (layerColl != null)
            {
                throw new SystemException("Custom LayIso already in use!");
            }
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            layerColl = new Dictionary&amp;lt;ObjectId, LayInfo&amp;gt;();
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                foreach (ObjectId id in (LayerTable)db.LayerTableId.GetObject(OpenMode.ForRead))
                {
                    LayerTableRecord layer = (LayerTableRecord)id.GetObject(OpenMode.ForWrite);
                    LayInfo layinfo = new LayInfo();
                    layinfo.Frozen = layer.IsFrozen;
                    layinfo.Off = layer.IsOff;
                    layinfo.Locked = layer.IsLocked;
                    layerColl.Add(id, layinfo);
                    if (layerstoisolate.Contains(layer.Name.ToUpper()))
                    {
                        layer.IsFrozen = false;
                        layer.IsLocked = false;
                        layer.IsOff = false;
                    }
                    else
                    {
                        layer.IsLocked = true;
                    }
                }
                
                tr.Commit();
                doc.Editor.Regen();
            }
        }

        public void UnisolateLayers()
        {
            if (layerColl == null)
                return;
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                foreach (KeyValuePair&amp;lt;ObjectId, LayInfo&amp;gt; pair in layerColl)
                {
                    LayerTableRecord layer = (LayerTableRecord)pair.Key.GetObject(OpenMode.ForWrite);
                    try
                    {
                        layer.IsFrozen = pair.Value.Frozen;
                    }
                    catch { }
                    layer.IsLocked = pair.Value.Locked;
                    layer.IsOff = pair.Value.Off;
                }
                tr.Commit();
                doc.Editor.Regen();
            }
            layerColl = null;
        }
    }

    class LayInfo
    {        
        public bool Frozen;
        public bool Off;
        public bool Locked;
    }
}
&lt;/PRE&gt;</description>
    <pubDate>Fri, 27 Nov 2015 21:23:22 GMT</pubDate>
    <dc:creator>Jeff_M</dc:creator>
    <dc:date>2015-11-27T21:23:22Z</dc:date>
    <item>
      <title>Is LAYISO available via the API?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/5927379#M37819</link>
      <description>&lt;P&gt;Is it possible to enable LAYISO with fading enabled via LISP or .Net? &amp;nbsp;I know there's a lot of routines out there to mimic the existing ALYISO command to remove the fade option but I require it for the application I'm writing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I'm looking for is a way to call LAYISO with a predetermined list of layers so the user doesn't have to select anything.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently using AutoCAD 2013.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2015 18:08:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/5927379#M37819</guid>
      <dc:creator>jdowthwaite</dc:creator>
      <dc:date>2015-11-27T18:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: Is LAYISO available via the API?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/5927499#M37820</link>
      <description>&lt;P&gt;Sitting here watching football I thought about what I would do for this. The following is what I came up with.&lt;/P&gt;
&lt;PRE&gt;using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using System;
using System.Collections.Generic;

namespace Misc_Commands.LayerTools
{
    public class NewLayIso
    {
        [CommandMethod("LayIsoThruCode")]
        public void layisothrucode()
        {
            List&amp;lt;string&amp;gt; layers = new List&amp;lt;string&amp;gt; { "C-ANNO", "C-ROAD" };
            IsolateLayers(layers);
        }

        [CommandMethod ("LayUnIsoThruCode")]
        public void unisothrucode()
        {
            UnisolateLayers();
        }

        private Dictionary&amp;lt;ObjectId, LayInfo&amp;gt; layerColl = null;

        /// &amp;lt;summary&amp;gt;
        /// Isolates a list of layer names
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="layerstoisolate"&amp;gt;Must be passed as a list of layer names using all UPPERCASE letters&amp;lt;/param&amp;gt;
        public void IsolateLayers(List&amp;lt;string&amp;gt; layerstoisolate)
        {
            if (layerColl != null)
            {
                throw new SystemException("Custom LayIso already in use!");
            }
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            layerColl = new Dictionary&amp;lt;ObjectId, LayInfo&amp;gt;();
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                foreach (ObjectId id in (LayerTable)db.LayerTableId.GetObject(OpenMode.ForRead))
                {
                    LayerTableRecord layer = (LayerTableRecord)id.GetObject(OpenMode.ForWrite);
                    LayInfo layinfo = new LayInfo();
                    layinfo.Frozen = layer.IsFrozen;
                    layinfo.Off = layer.IsOff;
                    layinfo.Locked = layer.IsLocked;
                    layerColl.Add(id, layinfo);
                    if (layerstoisolate.Contains(layer.Name.ToUpper()))
                    {
                        layer.IsFrozen = false;
                        layer.IsLocked = false;
                        layer.IsOff = false;
                    }
                    else
                    {
                        layer.IsLocked = true;
                    }
                }
                
                tr.Commit();
                doc.Editor.Regen();
            }
        }

        public void UnisolateLayers()
        {
            if (layerColl == null)
                return;
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                foreach (KeyValuePair&amp;lt;ObjectId, LayInfo&amp;gt; pair in layerColl)
                {
                    LayerTableRecord layer = (LayerTableRecord)pair.Key.GetObject(OpenMode.ForWrite);
                    try
                    {
                        layer.IsFrozen = pair.Value.Frozen;
                    }
                    catch { }
                    layer.IsLocked = pair.Value.Locked;
                    layer.IsOff = pair.Value.Off;
                }
                tr.Commit();
                doc.Editor.Regen();
            }
            layerColl = null;
        }
    }

    class LayInfo
    {        
        public bool Frozen;
        public bool Off;
        public bool Locked;
    }
}
&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Nov 2015 21:23:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/5927499#M37820</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2015-11-27T21:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: Is LAYISO available via the API?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/5930178#M37821</link>
      <description>&lt;P&gt;Thanks for the detailed reply Jeff but I've already written a version very close to that. &amp;nbsp;Unless I'm missing something, this doesn't show the isolated layers faded like LAYISO does.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2015 21:58:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/5930178#M37821</guid>
      <dc:creator>jdowthwaite</dc:creator>
      <dc:date>2015-11-30T21:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is LAYISO available via the API?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/5930625#M37822</link>
      <description>&lt;P&gt;Hi James,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think, Jeff's code should already do that.&lt;/P&gt;
&lt;P&gt;When a layer is locked, the entities in it get faded. So, entities in layers other than the one that is isolated are all faded.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that's not the behavior that you wanted, can you elaborate on it ?&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;
&lt;P&gt;Balaji&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2015 08:57:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/5930625#M37822</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2015-12-01T08:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: Is LAYISO available via the API?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/5931123#M37823</link>
      <description>&lt;P&gt;Balaji, Jeff,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are correct, the layers do fade (exactly the way I need them to) but they are still selectable. &amp;nbsp;After I fade the layers, I need to create a boundary region and the locked layers are still being identified.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2015 15:25:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/5931123#M37823</guid>
      <dc:creator>jdowthwaite</dc:creator>
      <dc:date>2015-12-01T15:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Is LAYISO available via the API?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/5935904#M37824</link>
      <description>&lt;P&gt;Hi James,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, that is the same behavior with AutoCAD's LAYISO command too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It prevents any changes to the entities in those locked layers but are still selectable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you do not want&amp;nbsp;them to be selectable, please try this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;[CommandMethod("LayIsoThruCode")]
public void layisothrucode()
{
    List&amp;lt;string&amp;gt; layers = new List&amp;lt;string&amp;gt; { "LAYER1" };
    IsolateLayers(layers);

    Document doc = Application.DocumentManager.MdiActiveDocument;
    doc.Editor.SelectionAdded += Editor_SelectionAdded;
}

void Editor_SelectionAdded(object sender, SelectionAddedEventArgs e)
{
    ObjectId[] addedIds = e.AddedObjects.GetObjectIds();
    Document doc = Application.DocumentManager.MdiActiveDocument;
    using (Transaction tr = doc.Database.TransactionManager.StartOpenCloseTransaction())
    {
        for (int i = 0; i &amp;lt; addedIds.Length; i++)
        {
            ObjectId oid = addedIds[i];
            Entity ent = tr.GetObject(oid, OpenMode.ForRead, false) as Entity;
            if (! ent.Layer.ToUpper().Equals("LAYER1"))
            {
                e.Remove(i);
            }
        }
        tr.Commit();
    }
}

[CommandMethod("LayUnIsoThruCode")]
public void unisothrucode()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    doc.Editor.SelectionAdded -= Editor_SelectionAdded;

    UnisolateLayers();
}
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This removes the entity object id from the selected list based on whether its layer was isolated or not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Balaji&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2015 10:50:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/5935904#M37824</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2015-12-04T10:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: Is LAYISO available via the API?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/5941619#M37825</link>
      <description>I guess I should have worded my original post better (and minus the spelling errors). What I really wanted was Jeff's answer combined with a flag on the Boundary command to ignore locked layers. Hind sight is 20/20.&lt;BR /&gt;&lt;BR /&gt;I'll mark Jeff's answer as a solution since he did answer my question.</description>
      <pubDate>Tue, 08 Dec 2015 15:15:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/5941619#M37825</guid>
      <dc:creator>jdowthwaite</dc:creator>
      <dc:date>2015-12-08T15:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: Is LAYISO available via the API?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/13656995#M85166</link>
      <description>&lt;P&gt;FYI locked layer will not fade correctly based on LAYLOCKFADECTL when locked w/ api, even when running a regen. Workaround from this post here is just to set the IsOff property when changing IsLocked property.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;layer.IsOff = layer.IsOff;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.keanw.com/2016/01/locking-and-unlocking-autocad-layers-visibly-using-net.html" target="_blank"&gt;https://www.keanw.com/2016/01/locking-and-unlocking-autocad-layers-visibly-using-net.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 May 2025 23:02:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/13656995#M85166</guid>
      <dc:creator>jules_g_pare</dc:creator>
      <dc:date>2025-05-29T23:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: Is LAYISO available via the API?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/13657187#M85167</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/17469065"&gt;@jules_g_pare&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;FYI locked layer will not fade correctly based on LAYLOCKFADECTL when locked w/ api, even when running a regen. Workaround from this post here is just to set the IsOff property when changing IsLocked property.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;LI-CODE lang="general"&gt;layer.IsOff = layer.IsOff;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.keanw.com/2016/01/locking-and-unlocking-autocad-layers-visibly-using-net.html" target="_blank" rel="noopener"&gt;https://www.keanw.com/2016/01/locking-and-unlocking-autocad-layers-visibly-using-net.html&lt;/A&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;What happens when you store LAYLOCKFADECTL current value, set it to zero, perform the layer lock operation(s), then restore&amp;nbsp;LAYLOCKFADECTL (without any regen)?&lt;/P&gt;</description>
      <pubDate>Fri, 30 May 2025 03:52:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-layiso-available-via-the-api/m-p/13657187#M85167</guid>
      <dc:creator>BlackBox_</dc:creator>
      <dc:date>2025-05-30T03:52:49Z</dc:date>
    </item>
  </channel>
</rss>

