<?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: How to check if entity is part of &amp;quot;Working Set&amp;quot;? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-check-if-entity-is-part-of-quot-working-set-quot/m-p/7278561#M30288</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;&lt;P&gt;This does look like what I need, but having trouble trying to reference it. I am obviously missing something here....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Here's an extension method for the Document class, that tells if the entity with the given ObjectId is in the working set:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;namespace Autodesk.AutoCAD.ApplicationServices
{
   public static class MyDocumentExtensions
   {
      public static bool WorkSetHas(this Document doc, ObjectId id, bool includingErased = true)
      {
         ObjectId id = Application.LongTransactionManager.CurrentLongTransactionFor(doc);
         if(!id.IsNull)
         {
            using(var trans = new ReadOnlyTransaction())
            {
               LongTransaction ltr = (LongTransaction) trans.GetObject(id, OpenMode.ForRead);
               return ltr.WorkSetHas(entityId, includingErased);
            }
         }
         return false;
      }
   }
}

namespace Autodesk.AutoCAD.DatabaseServices
{
   public class ReadOnlyTransaction : OpenCloseTransaction
   {
      protected override void DeleteUnmanagedObject()
      {
         Commit();
         base.DeleteUnmanagedObject();
      }

      public override void Abort()
      {
         Commit();
      }
   }
}&lt;/PRE&gt;</description>
    <pubDate>Sat, 05 Aug 2017 08:10:26 GMT</pubDate>
    <dc:creator>ActivistInvestor</dc:creator>
    <dc:date>2017-08-05T08:10:26Z</dc:date>
    <item>
      <title>How to check if entity is part of "Working Set"?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-check-if-entity-is-part-of-quot-working-set-quot/m-p/7278340#M30285</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to determine if an entity is part of the "Working Set". In other words, belongs to a Block or Xref that is currently being edited in-place.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the API have ability to check this?&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;Jon&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2017 00:55:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-check-if-entity-is-part-of-quot-working-set-quot/m-p/7278340#M30285</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-05T00:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if entity is part of "Working Set"?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-check-if-entity-is-part-of-quot-working-set-quot/m-p/7278364#M30286</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to determine if an entity is part of the "Working Set". In other words, belongs to a Block or Xref that is currently being edited in-place.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does the API have ability to check this?&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;Jon&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I think you're looking for the WorkSetHas() method of the LongTransaction class.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You get an instance of that class from the LongTransactionManager's CurrentLongTransactionFor() method.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2017 01:32:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-check-if-entity-is-part-of-quot-working-set-quot/m-p/7278364#M30286</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2017-08-05T01:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if entity is part of "Working Set"?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-check-if-entity-is-part-of-quot-working-set-quot/m-p/7278385#M30287</link>
      <description>&lt;P&gt;This does look like what I need, but having trouble trying to reference it. I am obviously missing something here....&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2017-08-04_22-06-48.png" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/386176iF2FA528109BCD6B0/image-size/large?v=v2&amp;amp;px=999" role="button" title="2017-08-04_22-06-48.png" alt="2017-08-04_22-06-48.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;OR&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2017-08-04_22-10-28.png" style="width: 689px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/386177i752AFC19273BC421/image-size/large?v=v2&amp;amp;px=999" role="button" title="2017-08-04_22-10-28.png" alt="2017-08-04_22-10-28.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2017 02:11:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-check-if-entity-is-part-of-quot-working-set-quot/m-p/7278385#M30287</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-05T02:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if entity is part of "Working Set"?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-check-if-entity-is-part-of-quot-working-set-quot/m-p/7278561#M30288</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;&lt;P&gt;This does look like what I need, but having trouble trying to reference it. I am obviously missing something here....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Here's an extension method for the Document class, that tells if the entity with the given ObjectId is in the working set:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;namespace Autodesk.AutoCAD.ApplicationServices
{
   public static class MyDocumentExtensions
   {
      public static bool WorkSetHas(this Document doc, ObjectId id, bool includingErased = true)
      {
         ObjectId id = Application.LongTransactionManager.CurrentLongTransactionFor(doc);
         if(!id.IsNull)
         {
            using(var trans = new ReadOnlyTransaction())
            {
               LongTransaction ltr = (LongTransaction) trans.GetObject(id, OpenMode.ForRead);
               return ltr.WorkSetHas(entityId, includingErased);
            }
         }
         return false;
      }
   }
}

namespace Autodesk.AutoCAD.DatabaseServices
{
   public class ReadOnlyTransaction : OpenCloseTransaction
   {
      protected override void DeleteUnmanagedObject()
      {
         Commit();
         base.DeleteUnmanagedObject();
      }

      public override void Abort()
      {
         Commit();
      }
   }
}&lt;/PRE&gt;</description>
      <pubDate>Sat, 05 Aug 2017 08:10:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-check-if-entity-is-part-of-quot-working-set-quot/m-p/7278561#M30288</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2017-08-05T08:10:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if entity is part of "Working Set"?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-check-if-entity-is-part-of-quot-working-set-quot/m-p/7278586#M30289</link>
      <description>&lt;P&gt;Thanks, that helped!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was missing Application before LongTransactionManager&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Dim oid As ObjectId = Autodesk.AutoCAD.ApplicationServices.Application.LongTransactionManager.CurrentLongTransactionFor(DocumentManager.MdiActiveDocument)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2017 08:56:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-check-if-entity-is-part-of-quot-working-set-quot/m-p/7278586#M30289</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-05T08:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if entity is part of "Working Set"?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-check-if-entity-is-part-of-quot-working-set-quot/m-p/7278825#M30290</link>
      <description>&lt;P&gt;Whoops.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote that one quickly and without testing it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In case anyone is interested, here is a working version:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;namespace Autodesk.AutoCAD.ApplicationServices
{
   public static class MyDocumentExtensions
   {
      public static bool WorkSetHas(this Document doc, ObjectId entityId, bool includingErased = true)
      {
         // Assert.IsNotNull(doc, "doc");
         ObjectId id = Application.LongTransactionManager.CurrentLongTransactionFor(doc);
         if(!id.IsNull)
         {
            using(var trans = new ReadOnlyTransaction())
            {
               LongTransaction ltr = (LongTransaction) trans.GetObject(id, OpenMode.ForRead);
               return ltr.WorkSetHas(entityId, includingErased);
            }
         }
         return false;
      }
   }
}

namespace Autodesk.AutoCAD.DatabaseServices
{
   public class ReadOnlyTransaction : OpenCloseTransaction
   {
      protected override void DeleteUnmanagedObject()
      {
         Commit();
         base.DeleteUnmanagedObject();
      }

      public override void Abort()
      {
         Commit();
      }
   }
}&lt;/PRE&gt;</description>
      <pubDate>Sat, 05 Aug 2017 13:37:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-check-if-entity-is-part-of-quot-working-set-quot/m-p/7278825#M30290</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2017-08-05T13:37:09Z</dc:date>
    </item>
  </channel>
</rss>

