- 积分
- 1074
- 明经币
- 个
- 注册时间
- 2002-11-28
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2004-12-28 11:04:00
|
显示全部楼层
迄今为止最为规范,最为完美的Delphi连接AutoCAD样板代码(by lazybones):
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComObj, AutoCAD_TLB;
type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); var acad:AcadApplication; line:Acadline; vpoint1,vpoint2:OleVariant; begin try acad:=GetActiveOleObject('AutoCAD.Application.16') as AcadApplication; except acad:=CreateOleObject('AutoCAD.Application.16') as AcadApplication; end; vpoint1:=varArrayCreate([0,2],varDouble); vpoint2:=varArrayCreate([0,2],varDouble); vpoint1[0]:=100.0; vpoint1[1]:=100.0; vpoint1[2]:=0.0; vpoint2[0]:=0.0; vpoint2[1]:=0.0; vpoint2[2]:=0.0; acad.Visible:=True; line:=acad.ActiveDocument.ModelSpace.Addline(vpoint1,vpoint2); line.Update; end;
end.
|
|