<?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 Setting the Document and Editor via Database in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/setting-the-document-and-editor-via-database/m-p/8887933#M21916</link>
    <description>&lt;P&gt;I generally define the AutoCAD three as shown in my modules:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using acApp = Autodesk.AutoCAD.ApplicationServices.Application;&lt;/P&gt;&lt;P&gt;private Document doc;&lt;BR /&gt;private Database db;&lt;BR /&gt;private Editor ed;&lt;BR /&gt;private void InitializeAutoCAD()&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;doc = acApp.DocumentManager.MdiActiveDocument;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;db = doc.Database;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ed = doc.Editor;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;However, I have been writing some Entity Extensions, and was passing the AutoCAD database as an argument.&amp;nbsp; But, I discovered that I could set the database via Entity.Database.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which now has me thinking and looking, but couldn't find a way to get the Document (and consequently the Editor) from the Database nor the Entity.&lt;/P&gt;&lt;P&gt;What I would like to do is lock the document, without having to pass the doc as an argument.&amp;nbsp; And, do Editor.WriteMessage in my catch, again without passing the argument.&lt;/P&gt;&lt;P&gt;Any one have a means to this end that will speed me along?&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jul 2019 13:18:45 GMT</pubDate>
    <dc:creator>dennis</dc:creator>
    <dc:date>2019-07-03T13:18:45Z</dc:date>
    <item>
      <title>Setting the Document and Editor via Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/setting-the-document-and-editor-via-database/m-p/8887933#M21916</link>
      <description>&lt;P&gt;I generally define the AutoCAD three as shown in my modules:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using acApp = Autodesk.AutoCAD.ApplicationServices.Application;&lt;/P&gt;&lt;P&gt;private Document doc;&lt;BR /&gt;private Database db;&lt;BR /&gt;private Editor ed;&lt;BR /&gt;private void InitializeAutoCAD()&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;doc = acApp.DocumentManager.MdiActiveDocument;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;db = doc.Database;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;ed = doc.Editor;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;However, I have been writing some Entity Extensions, and was passing the AutoCAD database as an argument.&amp;nbsp; But, I discovered that I could set the database via Entity.Database.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which now has me thinking and looking, but couldn't find a way to get the Document (and consequently the Editor) from the Database nor the Entity.&lt;/P&gt;&lt;P&gt;What I would like to do is lock the document, without having to pass the doc as an argument.&amp;nbsp; And, do Editor.WriteMessage in my catch, again without passing the argument.&lt;/P&gt;&lt;P&gt;Any one have a means to this end that will speed me along?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2019 13:18:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/setting-the-document-and-editor-via-database/m-p/8887933#M21916</guid>
      <dc:creator>dennis</dc:creator>
      <dc:date>2019-07-03T13:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: Setting the Document and Editor via Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/setting-the-document-and-editor-via-database/m-p/8888261#M21917</link>
      <description>&lt;P&gt;If I write Entity extension method, in general, I'd leave Document and/or Editor out of the extension methods' work scope, that is, not trying to lock document/write message with Editor... within extension method. This way, the logic in the extension method would only focus on entity itself. It would be the extension methods' calling process that should take the responsibility to call the extension method in proper context (locking document if necessary, write message of success/failure to the command line...).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume that you do know that an entity accessible in AutoCAD memory may not be database residing (created, but not being added to DB yet); When an entity is from a Database, the database could be a side database that does not have corresponding Document; When an entity from a Database of a Document, the Document's Editor may not be accessible (when the document is not the current active one... All these cases would limit your extension methods very limited applicable scope, if you use Document and/or Editor inside.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2019 15:10:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/setting-the-document-and-editor-via-database/m-p/8888261#M21917</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2019-07-03T15:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Setting the Document and Editor via Database</title>
      <link>https://forums.autodesk.com/t5/net-forum/setting-the-document-and-editor-via-database/m-p/8888279#M21918</link>
      <description>&lt;P&gt;Good points to consider Norman.&amp;nbsp; These specific extensions are being written with "my understanding" that the entities do indeed already exist in the drawing.&amp;nbsp; But your point of keeping extensions clean to the scope intended and having the calling handle the locking and messaging makes sense.&amp;nbsp; You have thought this out a little deeper than I have.&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2019 15:16:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/setting-the-document-and-editor-via-database/m-p/8888279#M21918</guid>
      <dc:creator>dennis</dc:creator>
      <dc:date>2019-07-03T15:16:39Z</dc:date>
    </item>
  </channel>
</rss>

