Unable to reference COM for AutoCAD 2006

Unable to reference COM for AutoCAD 2006

Anonymous
Not applicable
747 Views
3 Replies
Message 1 of 4

Unable to reference COM for AutoCAD 2006

Anonymous
Not applicable
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
0 Likes
748 Views
3 Replies
Replies (3)
Message 2 of 4

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

Regards - Nathan
0 Likes
Message 3 of 4

Anonymous
Not applicable
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
0 Likes
Message 4 of 4

Anonymous
Not applicable
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
0 Likes