autocad问题?(100分)

  • 主题发起人 主题发起人 yjhzzgl
  • 开始时间 开始时间
Y

yjhzzgl

Unregistered / Unconfirmed
GUEST, unregistred user!
我想在程序中打开cad划的图,可就是不行,请大富翁指教!
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,activex,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 acadConnect,acadApp:OleVariant;
begin
try
acadConnect:=GetActiveOleObject('AutoCAD.Application');
except
acadApp:=CreateOleObject('AutoCAD.Application');
end;
acadConnect.Visible:=True;
acadConnect:=acadApp.ActiveDocument;
acadApp.Documents.Open('D:/Program Files/AutoCAD 2004/Sample/wilhome.dwg',true,'');
end;

end.
 
imgFileNameTemp := 'c:/gc_gctz.dwg';
l_FileStream := TFileStream.Create('c:/gc_gctz.dwg', fmOpenWrite or fmCreate);
TBlobField(qry_gctz.Fields.Fields[6]).SaveToStream(l_FileStream);
l_FileStream.Free;

cad:=CreateoleObject('AutoCAD.Application');
//cad.visible:=true;
caddoc:=cad.ActiveDocument;
//改变当前背景颜色为白色
cad.Preferences.Display.GraphicsWinModelBackgrndColor:= clblack;
//改变当前命令行为1行
cad.Preferences.Display.DockedVisibleLines:= 1;
//设置模式为单文档
caddoc.SetVariable('SDI',1);
//调入新文件
caddoc.Application.Documents.Open('c:/gc_gctz.dwg', False);
t_SelectionSet:=caddoc.SelectionSets.Add('NewSelSet');
t_SelectionSet.Select(5);
caddoc.Export( 'c:/' + 'gc_gctz', 'WMF', t_SelectionSet);
Picture.LoadFromFile('c:/gc_gctz.WMF');
cad.quit;
 
to andy263:
老大,能否详细一点,不胜感谢!
 
哪位大富翁帮我看看,不胜感谢!
 
郁闷!!!!!!!!!!!!!!
 
有没有人会啊?指教一下!
 
如果是 AutoCAD 2000 用:
acadApp.Documents.Open('D:/Program Files/AutoCAD 2004/Sample/wilhome.dwg');

如果是 AutoCAD R14 用:
acadApp.ActiveDocument.Open('D:/Program Files/AutoCAD 2004/Sample/wilhome.dwg');

记得给分
 
多人接受答案了。
 
后退
顶部