<?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: Turn custom Service on/off per Drawing in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/turn-custom-service-on-off-per-drawing/m-p/9346619#M20217</link>
    <description>&lt;P&gt;Thanks for the reply.&amp;nbsp; The flag would definitely need to persist between sessions, and I think I was thinking along the same lines as that when i asked the question.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A follow up question I have though is related to the flags.&amp;nbsp; I am not familiar with what you mean by the flag.&amp;nbsp; Is it simply a string or bool stored under a variable name in the User.Data?&amp;nbsp; Or is it a specific structure or Object I need to store in the drawing?&amp;nbsp; I am just not familiar with the terminology you used, so apologies if it's a lot simpler than I am making it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Feb 2020 19:07:00 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-02-27T19:07:00Z</dc:date>
    <item>
      <title>Turn custom Service on/off per Drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/turn-custom-service-on-off-per-drawing/m-p/9344023#M20215</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a custom service that logs different events in a Document to a text file for review at a later date.&lt;BR /&gt;&lt;BR /&gt;There is desire for this to be a toggle-able feature for any given document. We want the default to be off, and the user should be allowed to turn it on if it's desired for that given drawing. What is the best way to store whether or not the logging service should be used in a drawing?&amp;nbsp; Is this something that should be stored in XData/XRecord, or am I thinking along the wrong lines there?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advanced for any input on this &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 21:05:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/turn-custom-service-on-off-per-drawing/m-p/9344023#M20215</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-26T21:05:40Z</dc:date>
    </item>
    <item>
      <title>Re: Turn custom Service on/off per Drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/turn-custom-service-on-off-per-drawing/m-p/9345868#M20216</link>
      <description>&lt;P&gt;It would depend on whether the on/off flag only takes effect within one AutoCAD session, or across multiple AutoCAD session (i.e. the drawing has to store/remember the on/off flag).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Obviously, if only in one AutoCAD session, things would be really easy: the logging app (AutoCAD add-in, I suppose) could simply keep a drawing list that user choose to run logging process against to. Or, as alternative, you can set flag as "per drawing" data, such as Document.UserData (a HashTable type), and let the logging process check each open drawing's UserData to decide if the flag is set or not, or, on or off.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the flag has to take effect acrossing AutoCAD session, obviously, you need to save it with drawing. Since it is "per drawing" and most likely has nothing to do with the contents/individual entities, I'd use NamedDictionary (thus, the actual flag data would be XRecord to be added into your named dictionary).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would do this roughly like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Make the Add-in implement IExtenstionApplication, so that when the app is loaded, the code would check each opened drawing's NamedDictionary. If the flag dictionary is found, retrieve the flag data from the dictionary to a custom class, then save the class in the Document.UserData;&lt;/P&gt;
&lt;P&gt;2. If user chooses to set the flag on/off on a opened drawing, add/remove the custom flag data to/from Document.UserData;&lt;/P&gt;
&lt;P&gt;3. Handle document event (DocumentToBeDestroyed, for example), where the Document.UserData is examined for the flag data, save it into flag named dictionary, or clear the dictionary, depending on the flag being on or off.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since the flag is across drawing session and set by certain user, the flag data may want to also include user name/computer name..., so that when the drawing is opened by other user, he/she may have his/her own flag set on/off (if the business operation workflow has such requirement).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just an idea. There could be many other options.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2020 14:34:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/turn-custom-service-on-off-per-drawing/m-p/9345868#M20216</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2020-02-27T14:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: Turn custom Service on/off per Drawing</title>
      <link>https://forums.autodesk.com/t5/net-forum/turn-custom-service-on-off-per-drawing/m-p/9346619#M20217</link>
      <description>&lt;P&gt;Thanks for the reply.&amp;nbsp; The flag would definitely need to persist between sessions, and I think I was thinking along the same lines as that when i asked the question.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A follow up question I have though is related to the flags.&amp;nbsp; I am not familiar with what you mean by the flag.&amp;nbsp; Is it simply a string or bool stored under a variable name in the User.Data?&amp;nbsp; Or is it a specific structure or Object I need to store in the drawing?&amp;nbsp; I am just not familiar with the terminology you used, so apologies if it's a lot simpler than I am making it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2020 19:07:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/turn-custom-service-on-off-per-drawing/m-p/9346619#M20217</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-27T19:07:00Z</dc:date>
    </item>
  </channel>
</rss>

