Connect to AutoCAD 2007 -- Delphi 7

Connect to AutoCAD 2007 -- Delphi 7

Anonymous
Not applicable
1,391 Views
3 Replies
Message 1 of 4

Connect to AutoCAD 2007 -- Delphi 7

Anonymous
Not applicable
I've been using the following procedure to establish a COM connection to AutoCAD in versions 2000, 2005, and 2006. Never had a problem. Now that I've installed 2007, I can't establish a connection.

[pre]
procedure ConnectToAcad(var Acad: AcadApplication);
var
ErrorMessage: string;
begin
try
Acad := IDispatch(GetActiveOleObject('AutoCAD.Application.17')) as
AcadApplication;
if not Acad.Visible then
begin
Acad.Visible := TRUE;
end;
except
try
Acad := IDispatch(CreateOleObject('AutoCAD.Application.17')) as
AcadApplication;
Acad.Application.WindowState := acMax;
Acad.Visible := TRUE;
except
Beep;
ErrorMessage := 'Could not establish a connection to AutoCAD.';
ShowMessage(ErrorMessage);
Exit;
end;
end;
end;
[/pre]

Note: When I open the Task Manager after calling the procedure, a new instance of acad.exe appears on the process list.
0 Likes
1,392 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
The error message I get when executing the program from the IDE is "interface not supported".

Any help on how to resolve this would be much appreciated.
0 Likes
Message 3 of 4

Anonymous
Not applicable
Problem resolved. I failed to properly import the version 17 type library.
0 Likes
Message 4 of 4

Anonymous
Not applicable
Did you import the AutoCAD 2007 type library?

Sure you not using an AutoCAD_TLB.pas from an earler release?

The only interface you're using is IAcadApplication, so if you're
using the right type library, then the next step would be to change
that variable to late-bound (IDispatch) and see what happens then.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:[email protected]...
The error message I get when executing the program from the IDE is "interface not supported".

Any help on how to resolve this would be much appreciated.
0 Likes