Message 1 of 4
Connect to AutoCAD 2007 -- Delphi 7
Not applicable
11-17-2006
09:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
[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.