<?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 Lock layers in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/lock-layers/m-p/13297019#M932</link>
    <description>&lt;P&gt;Hi, is there a simpler solution to automatically lock a layer that has been unlocked by the user? I have some layers that I do not want to be unlocked.&lt;BR /&gt;I currently have a solution that uses OnCommandEnded, but it is not as elegant as I want it to be.&lt;/P&gt;&lt;P&gt;I thought about an Eventhandler attached to the specific layers, but all my tests failed into AutoCAD crashing as the layer was already being modified by AutoCAD (if I understood correctly), delaying the modification didn't work either.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Mon, 03 Feb 2025 15:13:08 GMT</pubDate>
    <dc:creator>julian.schoenenberger</dc:creator>
    <dc:date>2025-02-03T15:13:08Z</dc:date>
    <item>
      <title>Lock layers</title>
      <link>https://forums.autodesk.com/t5/net-forum/lock-layers/m-p/13297019#M932</link>
      <description>&lt;P&gt;Hi, is there a simpler solution to automatically lock a layer that has been unlocked by the user? I have some layers that I do not want to be unlocked.&lt;BR /&gt;I currently have a solution that uses OnCommandEnded, but it is not as elegant as I want it to be.&lt;/P&gt;&lt;P&gt;I thought about an Eventhandler attached to the specific layers, but all my tests failed into AutoCAD crashing as the layer was already being modified by AutoCAD (if I understood correctly), delaying the modification didn't work either.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 15:13:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/lock-layers/m-p/13297019#M932</guid>
      <dc:creator>julian.schoenenberger</dc:creator>
      <dc:date>2025-02-03T15:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Lock layers</title>
      <link>https://forums.autodesk.com/t5/net-forum/lock-layers/m-p/13297162#M933</link>
      <description>&lt;P&gt;The possible solution is not to relock the layer after users unlock it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might want to try to use ObjectOverrule to prevent the layer being unlocked, that is, in the overridden Close() method, you can test if the target layer that being opened for writing is unlocked, if it is, throw an AutoCAD runtime exception, which would effectively abort the change. You might want to let users be aware the layer unlock is denied by your code, so that they are not confused as why AutoCAD does not work properly as they thought.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 16:39:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/lock-layers/m-p/13297162#M933</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2025-02-03T16:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Lock layers</title>
      <link>https://forums.autodesk.com/t5/net-forum/lock-layers/m-p/13297384#M934</link>
      <description>&lt;P&gt;This sounds like a training / drawing management issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the layers must reside in a drawing the user has modify access to on your server, train them.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the layers can exist outside of the drawing they have modify access to on your server, consider placing the layers you don't want modified in a separate drawing, that they can XREF, but do not have modify access to.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 18:18:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/lock-layers/m-p/13297384#M934</guid>
      <dc:creator>BlackBox_</dc:creator>
      <dc:date>2025-02-03T18:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Lock layers</title>
      <link>https://forums.autodesk.com/t5/net-forum/lock-layers/m-p/13297956#M935</link>
      <description>&lt;P&gt;Long ago, I built a library of overrules for cadd standards enforcement, and one of them targets layers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While the existing code didn't specifically target your use case, It was trivial to modify it to do what you need.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code below also requires the code in &lt;A href="https://github.com/ActivistInvestor/AcMgdUtility/tree/main/LayerOverrule" target="_blank" rel="noopener"&gt;this repository folder&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;   /// &amp;lt;summary&amp;gt;
   /// Example showing how to use the LayerOverrule
   /// base type (included in LayerOverrule.cs).
   /// 
   /// This example prevents layers from being locked
   /// only if their name starts with "NOLOCK", which
   /// is just an example. Real-world application of
   /// this class can involve realistic criteria.
   /// 
   /// Issue:
   /// 
   /// The Layer properties manager does not update to
   /// display the correct locked/unlocked state of a
   /// layer which the user tried to lock via the layer
   /// manager dialog. 
   /// 
   /// So, if the user tries to lock a layer that this
   /// overrule does not allow them to lock, the layer
   /// properties manager will show the layer as being
   /// locked, even thought it is not locked.
   /// 
   /// The LayerManagerThunk class included in the code
   /// file required by this example addresses that issue,
   /// by forcing the LayerManager control to update when
   /// the user tries to lock a layer that can't be locked.
   /// 
   /// &amp;lt;/summary&amp;gt;

   public class MyNoLockLayerOverrule : LayerOverrule
   {
      public MyNoLockLayerOverrule() : base("NOLOCK*")
      {
      }

      /// &amp;lt;summary&amp;gt;
      /// The base type filters the layers by their names
      /// according to the string passed to its constructor
      /// above, so this method will only be called if the 
      /// layer's name matches the wildcard pattern "NOLOCK*".
      /// 
      /// You can change the pattern to meet your needs or
      /// you can override the IsMatch() method to directly
      /// specify what layers the overrule should act on.
      /// &amp;lt;/summary&amp;gt;

      protected override void OnLayerModified(LayerTableRecord layer)
      {
         if(layer.IsLocked)
         {
            layer.IsLocked = false;
            LayerManagerThunk.UpdateLayerManager(true);
            Async.WriteLine($"\nALERT: Layer {layer.Name} cannot be locked!");
         }
      }
   }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 01:51:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/lock-layers/m-p/13297956#M935</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2025-02-04T01:51:23Z</dc:date>
    </item>
  </channel>
</rss>

