.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unable to reference COM for AutoCAD 2006

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
289 Views, 3 Replies

Unable to reference COM for AutoCAD 2006

In VB.net (2003) I can set a reference to AutoCAD 2000 type library from the
COM tab.
Then, using:

Imports AutoCAD

'the following variables can be declared...
Public AcadDoc As AcadDocument, AcadApp As AcadApplication

'and this will connect to the current AutoCAD session & Drawing.
AcadApp = GetObject(, AutoCAD.Application.15)
AcadDoc = AcadApp.ActiveDocument



But, I can't seem to do the same thing for AutoCAD 2006. Reference is set
for AutoCAD 2006
type library from the COM tab. Also using:

Imports AutoCAD 'error: namespace or type cannot be found

'the following variables can't be declared...
Public AcadDoc As AcadDocument, AcadApp As AcadApplication
'error: both show 'type not defined'

'and this can't work because the object variables are'nt set.
AcadApp = GetObject(, AutoCAD.Application.16.2)
AcadDoc = AcadApp.ActiveDocument


Any help or nudge in the right direction would be much appreciated.

Marty
3 REPLIES 3
Message 2 of 4
NathTay
in reply to: Anonymous

Add another reference to the AutoCAD/ObjectDBX Common 16.0 Type Library.

Regards - Nathan
Message 3 of 4
Anonymous
in reply to: Anonymous

Thanks Nathan... I added the reference, but the "Imports AutoCAD" statement
still isn't recognized as a valid namespace.

Is there a different or multiple "Imports" statement that's needed now for
AutoCAD 2006 to interact with COM from vb.net?

Marty


wrote in message news:4949758@discussion.autodesk.com...
Add another reference to the AutoCAD/ObjectDBX Common 16.0 Type Library.

Regards - Nathan
Message 4 of 4
Anonymous
in reply to: Anonymous

I'm able to set the COM references now to AutoCAD as:
AutoCAD 2006 Type Library 1.1
AutoCAD/ObjectDBX Common 16.0 Type Library

... these statements work now. (before, the .Common did not show up as a
choice, but does now).
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common

For some reason there were double entries (and versions) in
C:\WINDOWS\assembly for:
Autodesk.AutoCAD.Interop
Autodesk.AutoCAD.Interop.Common

Uninstalling AutoCAD took care of one set of entries. But had to regedit
(delete) the other two
from \installer\assemblies\global so that they could be deleted from the
C:\windows\assembly folder.
Maybe these were left over when upgrading from AutoCAD 2005????

Anyway, after reinstalling AutoCAD it appears to be working. And, now... I'm
looking forward
to RELEARNING the object model & REWRITING all of my VB 6 AutoCAD apps. ;-(


Marty

"Marty" wrote in message
news:4949641@discussion.autodesk.com...
In VB.net (2003) I can set a reference to AutoCAD 2000 type library from the
COM tab.
Then, using:

Imports AutoCAD

'the following variables can be declared...
Public AcadDoc As AcadDocument, AcadApp As AcadApplication

'and this will connect to the current AutoCAD session & Drawing.
AcadApp = GetObject(, AutoCAD.Application.15)
AcadDoc = AcadApp.ActiveDocument



But, I can't seem to do the same thing for AutoCAD 2006. Reference is set
for AutoCAD 2006
type library from the COM tab. Also using:

Imports AutoCAD 'error: namespace or type cannot be found

'the following variables can't be declared...
Public AcadDoc As AcadDocument, AcadApp As AcadApplication
'error: both show 'type not defined'

'and this can't work because the object variables are'nt set.
AcadApp = GetObject(, AutoCAD.Application.16.2)
AcadDoc = AcadApp.ActiveDocument


Any help or nudge in the right direction would be much appreciated.

Marty

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost