<?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 GetAcadDocument in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/getacaddocument/m-p/3390287#M56536</link>
    <description>&lt;P&gt;I'm having trouble trying to get the GetAcadDocument method to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2012 code:&lt;/P&gt;&lt;P&gt;ThisDrawing = DocumentManager.MdiActiveDocument.AcadDocument&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2013:&lt;/P&gt;&lt;P&gt;ThisDrawing = DocumentExtension.GetAcadDocument(Application.DocumentManager.MdiActiveDocument)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Produces a run time error. &amp;nbsp;I know just enough .net to brute force my app to do what I want and would appreciate any help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Phil&lt;/P&gt;</description>
    <pubDate>Wed, 28 Mar 2012 23:31:16 GMT</pubDate>
    <dc:creator>Pfilc</dc:creator>
    <dc:date>2012-03-28T23:31:16Z</dc:date>
    <item>
      <title>GetAcadDocument</title>
      <link>https://forums.autodesk.com/t5/net-forum/getacaddocument/m-p/3390287#M56536</link>
      <description>&lt;P&gt;I'm having trouble trying to get the GetAcadDocument method to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2012 code:&lt;/P&gt;&lt;P&gt;ThisDrawing = DocumentManager.MdiActiveDocument.AcadDocument&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2013:&lt;/P&gt;&lt;P&gt;ThisDrawing = DocumentExtension.GetAcadDocument(Application.DocumentManager.MdiActiveDocument)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Produces a run time error. &amp;nbsp;I know just enough .net to brute force my app to do what I want and would appreciate any help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Phil&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2012 23:31:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getacaddocument/m-p/3390287#M56536</guid>
      <dc:creator>Pfilc</dc:creator>
      <dc:date>2012-03-28T23:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: GetAcadDocument</title>
      <link>https://forums.autodesk.com/t5/net-forum/getacaddocument/m-p/3390475#M56537</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for me it's running (it used time to find the alternative to&amp;nbsp;&lt;FONT color="#666699" face="lucida sans unicode,lucida sans"&gt;.AcadDocument&lt;/FONT&gt; but with the method same to yours it's working for me. How is &lt;FONT color="#666699" face="lucida sans unicode,lucida sans"&gt;ThisDrawing&lt;/FONT&gt; declared at your code, what runtime-error do you get exactly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2012 06:29:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getacaddocument/m-p/3390475#M56537</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2012-03-29T06:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: GetAcadDocument</title>
      <link>https://forums.autodesk.com/t5/net-forum/getacaddocument/m-p/3391351#M56538</link>
      <description>&lt;P&gt;Thanks for the response Alfred...confirming the code was ok made me look for a more fundamental problem and I realized I had a bad reference.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2012 15:44:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getacaddocument/m-p/3391351#M56538</guid>
      <dc:creator>Pfilc</dc:creator>
      <dc:date>2012-03-29T15:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: GetAcadDocument</title>
      <link>https://forums.autodesk.com/t5/net-forum/getacaddocument/m-p/4344648#M56539</link>
      <description>&lt;P&gt;Greetings, I have the same problem you had, I would like you to help me solve mine, with some questions&lt;BR /&gt;. How did you fix it?&lt;BR /&gt;- Versiond and vb.net What did you use?&lt;BR /&gt;- What version of AutoCAD are you?&lt;BR /&gt;- What references did you use?&lt;/P&gt;&lt;P&gt;I await your reply, thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2013 15:25:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getacaddocument/m-p/4344648#M56539</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-07-26T15:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: GetAcadDocument</title>
      <link>https://forums.autodesk.com/t5/net-forum/getacaddocument/m-p/4345576#M56541</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just a little precision about GetAcadDocument() method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's an extension method which extents the Document type (defining extension isn't exactly the same with &lt;A rel="nofollow" target="_blank" href="http://msdn.microsoft.com/en-us/library/bb383977.aspx"&gt;C#&lt;/A&gt; or &lt;A rel="nofollow" target="_blank" href="http://msdn.microsoft.com/en-us/library/bb384936.aspx"&gt;VB&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Extension methods can be called both way (assuming doc = MdiActivedocument):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- as static (Shared) methods as shown upper:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;ThisDrawing = DocumentExension.GetAcadDocument(doc)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- as instance methods of the extended type:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;ThisDrawing = doc.GetAcadDocument()&lt;/EM&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second one will directly work with C# because DocumentExtension is a class of the ApplicationServices namespace.&lt;/P&gt;&lt;P&gt;But with VB extension methods have to be defined in a Module, so, the&amp;nbsp;DocumentExtension module have to be imported for this behavior to be available.&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Imports Autodesk.AutoCAD.ApplicationServices.DocumentExtension&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jul 2013 10:51:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getacaddocument/m-p/4345576#M56541</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2013-07-28T10:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: GetAcadDocument</title>
      <link>https://forums.autodesk.com/t5/net-forum/getacaddocument/m-p/6867340#M56542</link>
      <description>&lt;P&gt;Gilles,&lt;/P&gt;&lt;P&gt;I am moving over my VB app to C#.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used this in VB&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Public ReadOnly Property ThisDrawing() as AcadDocument&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Get&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Core.Application.DocumentManager.MdiActiveDocument.GetAcadDocument()&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;End Get&lt;/P&gt;&lt;P&gt;End Property&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then in a different sub&lt;/P&gt;&lt;P&gt;ThisDrawing.ObjectSnapMode = False &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I couldn't do this in C# so I tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;private readonly Document roDocument = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;public object ThisDrawing&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;get&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return roDocument.GetAcadDocument();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then in a different sub&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ThisDrawing.ObjectSnapMode = False &amp;nbsp; - however ObjectSnapMode does not come up.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Do you have any ideas?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 21:42:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getacaddocument/m-p/6867340#M56542</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-02-09T21:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: GetAcadDocument</title>
      <link>https://forums.autodesk.com/t5/net-forum/getacaddocument/m-p/6867388#M56543</link>
      <description>&lt;P&gt;Your C# code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;public object ThisDrawing&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;{&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;get&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return roDocument.GetAcadDocument();&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;is not exactly equivalent to the original VB.NET code:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;Public ReadOnly Property ThisDrawing() as AcadDocument&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Get&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Core.Application.DocumentManager.MdiActiveDocumen&lt;WBR /&gt;t.GetAcadDocument()&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;End Get&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;End Property&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the VB.NET code, the property ThisDrawing is a type of &lt;STRONG&gt;AcadDocument&lt;/STRONG&gt; (you must had reference to AutoCAD's COM API), while in the C# code, the same property ThisDrawing is type of &lt;STRONG&gt;object&lt;/STRONG&gt;, thus you cannot have code like ThisDrawing.ObjectSnapMode=..... To make the C# code the same as VB.NET, you need to add reference to AutoCAD COM API and expose the property ThisDrawing as AcadDocument.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, unless it is really necessary, in most cases, there is no need to mix COM APIs in the .NET API development, especially the VBA style of "ThisDrawing" shown in various code examples available on the net is bad-taste code used in AutoCAD .NET API programming, IMO.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 21:55:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getacaddocument/m-p/6867388#M56543</guid>
      <dc:creator>Norman_Yuan</dc:creator>
      <dc:date>2017-02-09T21:55:08Z</dc:date>
    </item>
  </channel>
</rss>

