X
xinun
Unregistered / Unconfirmed
GUEST, unregistred user!
我现在正在开发一个在Delphi中的调用Autocad区划一组封闭的直线,然后再将其拉伸(Extrude)成一个实体(solid),有关在Delphi程序中调出Auotcad以及画出这一组封闭的直线都是非常容易的,但是我不知道如何将这一组直线先形成一个域(region),我知道是先用函数Addregion,但是在运行程序之后,Autocad也被调出来区画了那组封闭直线,但等到运行到函数Addregion时,系统总是告诉我“程序发生致命性错误”,我不知道为什么,但我断定是很可能因为Addregion函数中的被调用参数的类型的错误。如果有那位高手知道如何调用这个Addregion函数也可以通过email:yunxin88@263.net告诉我,最好是能有程序代码。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,comobj;
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
p1, p2, p3: OleVariant; // start & end points of line
Mspace, regionObject ,Acad, AcadDocument1, lineObject , solidObject ,AcadDocument,lineobj : OleVariant;
begin
p1 := VarArrayCreate([0, 2], 5);
p2 := VarArrayCreate([0, 2], 5);
p3 := VarArrayCreate([0, 2], 5);
// Assign values to array elements
p1[0] := 2.0; p1[1] := 4.0; p1[2] := 0.0;// from 2,4,0
p2[0] := 12.0; p2[1] := 14.0; p2[2] := 0.0; // to 12,14,0
p3[0] := 7.0; p3[1] := 8.0; p3[2] := 0.0;
lineObject:= VarArrayCreate([0, 11],varVariant) ;
Acad:= CreateOleObject('AutoCad.Application');
Acad.visible:= True ;
AcadDocument:=Acad.Documents;
AcadDocument1:=Acad.ActiveDocument;
Mspace := AcadDocument1.ModelSpace;
lineobj[1] := Mspace.AddLine(VarArrayRef(p1), VarArrayRef(p2));
lineobj[2] := Mspace.AddLine(VarArrayRef(p2), VarArrayRef(p3));
lineobj[3] := Mspace.AddLine(VarArrayRef(p3), VarArrayRef(p1));
regionObject:=Mspace.AddRegion(lineObject);
solidObject:=MSpace.AddExtrudedSolid(regionObject[0], solidlength, 0) ;
end
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,comobj;
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
p1, p2, p3: OleVariant; // start & end points of line
Mspace, regionObject ,Acad, AcadDocument1, lineObject , solidObject ,AcadDocument,lineobj : OleVariant;
begin
p1 := VarArrayCreate([0, 2], 5);
p2 := VarArrayCreate([0, 2], 5);
p3 := VarArrayCreate([0, 2], 5);
// Assign values to array elements
p1[0] := 2.0; p1[1] := 4.0; p1[2] := 0.0;// from 2,4,0
p2[0] := 12.0; p2[1] := 14.0; p2[2] := 0.0; // to 12,14,0
p3[0] := 7.0; p3[1] := 8.0; p3[2] := 0.0;
lineObject:= VarArrayCreate([0, 11],varVariant) ;
Acad:= CreateOleObject('AutoCad.Application');
Acad.visible:= True ;
AcadDocument:=Acad.Documents;
AcadDocument1:=Acad.ActiveDocument;
Mspace := AcadDocument1.ModelSpace;
lineobj[1] := Mspace.AddLine(VarArrayRef(p1), VarArrayRef(p2));
lineobj[2] := Mspace.AddLine(VarArrayRef(p2), VarArrayRef(p3));
lineobj[3] := Mspace.AddLine(VarArrayRef(p3), VarArrayRef(p1));
regionObject:=Mspace.AddRegion(lineObject);
solidObject:=MSpace.AddExtrudedSolid(regionObject[0], solidlength, 0) ;
end