<?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 connect AutoCAD (user specified version) using VB.Net via COM Library? in AutoCAD Forum</title>
    <link>https://forums.autodesk.com/t5/autocad-forum/how-to-connect-autocad-user-specified-version-using-vb-net-via/m-p/12572995#M20967</link>
    <description>&lt;P&gt;.net forum is over here&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/net/bd-p/152" target="_blank"&gt;https://forums.autodesk.com/t5/net/bd-p/152&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Feb 2024 08:15:18 GMT</pubDate>
    <dc:creator>paullimapa</dc:creator>
    <dc:date>2024-02-21T08:15:18Z</dc:date>
    <item>
      <title>How to connect AutoCAD (user specified version) using VB.Net via COM Library?</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/how-to-connect-autocad-user-specified-version-using-vb-net-via/m-p/12572900#M20966</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dear Team,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my Vb.Net Project,&amp;nbsp; connecting AutoCAD 2020 using the COM type Library by selecting the Reference&amp;nbsp; (AutoCAD Version 2020)&amp;nbsp;manually &amp;amp; Internally code modified the version 2020. Its working fine.&lt;/P&gt;&lt;P&gt;(Cannot change to Net Library, built lot of Standard functions based on this COM)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suppose if user want to connect AutoCAD 2024, once again i have to modify the COM Reference (AutoCAD Version - 2024)&amp;nbsp; then will modify the connection portion inside the code based on version.&lt;/P&gt;&lt;P&gt;For Each user we can't built Project, not good Automation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Query : Based on User Input (Version2024), connect AutoCAD 2024 via COM Library, along with reference base version 2020?&amp;nbsp; (Is it possible Deselect 2020 reference and Select 2024 Reference inside code?)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this code, not working - results in Error.&lt;/P&gt;&lt;P&gt;Please give Suggestions to achieve this,&amp;nbsp;&lt;SPAN&gt;Thanks by advance.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Code Snippet:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Need to open AutoCAD 2024:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&amp;nbsp;' -Manually&amp;nbsp; added AutoCAD 2020 reference (below picture) - for built up the project&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;Public Shared Sub connect_cad()&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'CAD_Version&amp;nbsp; -- user input&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 'Dim CAD_Version As String = "AutoCAD.Application.23.1"&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'Autocad 2020 user input&amp;nbsp;&lt;FONT color="#FF0000"&gt; (working fine)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Dim CAD_version As String = "AutoCAD.Application.24.3"&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ' AutoCAD 2024 user input&amp;nbsp;&lt;FONT color="#FF0000"&gt; (getting error)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;Try&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Cadapp = CType(System.Runtime.InteropServices.Marshal.GetActiveObject(CAD_version), AcadApplication) ''&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; GetObject(, "AutoCAD.Application")&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If&amp;nbsp; Cadapp.Documents.Count = 0 Then Cadapp.Documents.Add()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Caddoc = Cadapp.ActiveDocument&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Cadapp.WindowState = AcWindowState.acMax&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Cadapp.Visible = True&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;Catch Ex As Exception&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If Err.Number &amp;lt;&amp;gt; 0 Then&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CADOPEN = False&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Err.Clear()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Cadapp = CType(CreateObject(CAD_version), AcadApplication)&amp;nbsp; &lt;FONT color="#FF0000"&gt;&amp;nbsp;'Error coming here&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If Err.Number &amp;lt;&amp;gt; 0 Then&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CADOPEN = False&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MsgBox(Err.Description)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Exit Sub&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; End If&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Cadapp.WindowState = AcWindowState.acMax&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Cadapp.Visible = True&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Caddoc = Cadapp.ActiveDocument&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;Else&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If Cadapp.Documents.Count = 0 Then Cadapp.Documents.Add()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Caddoc = Cadapp.ActiveDocument&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;conect_cad_option = True&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Cadapp.WindowState = AcWindowState.acMax&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Cadapp.Visible = True&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; End If&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;Finally&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;End Try&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" size="3" color="#0000FF"&gt;End Sub&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;FONT color="#FF0000"&gt;Error Msg:&lt;/FONT&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="times new roman,times" color="#FF0000"&gt;System.InvalidCastException: 'Unable to cast COM object of type 'System.__ComObject' to interface type 'AutoCAD.AcadApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{6323190E-C6ED-434C-A368-E9314A8D7597}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This Picture - Manually added Reference for AutoCAD Version 2020&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="muthukumarkVVK9E_0-1708497922652.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1328536iC2CE5B6CE8FFCB83/image-size/large?v=v2&amp;amp;px=999" role="button" title="muthukumarkVVK9E_0-1708497922652.png" alt="muthukumarkVVK9E_0-1708497922652.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 07:11:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/how-to-connect-autocad-user-specified-version-using-vb-net-via/m-p/12572900#M20966</guid>
      <dc:creator>muthukumar.kVVK9E</dc:creator>
      <dc:date>2024-02-21T07:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to connect AutoCAD (user specified version) using VB.Net via COM Library?</title>
      <link>https://forums.autodesk.com/t5/autocad-forum/how-to-connect-autocad-user-specified-version-using-vb-net-via/m-p/12572995#M20967</link>
      <description>&lt;P&gt;.net forum is over here&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/net/bd-p/152" target="_blank"&gt;https://forums.autodesk.com/t5/net/bd-p/152&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 08:15:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-forum/how-to-connect-autocad-user-specified-version-using-vb-net-via/m-p/12572995#M20967</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2024-02-21T08:15:18Z</dc:date>
    </item>
  </channel>
</rss>

