关于delphi对cad二次开发的问题
我现在在写一个关于delphi对cad二次开发的程序,如下图,想要找一条竖线,与多条斜线有2个交点时画出这条竖线(图中红色的线)。程序代码:unit Unit1;interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ComObj,ActiveX;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
obj_Doc,obj_ModelSpace, obj_Acad: Variant;
boo:boolean;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
boo:=false;
try
obj_Acad:=GetActiveOleObject('AutoCAD.Application');
except
obj_Acad:=CreateOleObject('AutoCad.Application');
end;
obj_Acad.visible:=True;
obj_Doc:=obj_Acad.ActiveDocument;
obj_ModelSpace:=obj_Doc.ModelSpace;
obj_Acad.zoomextents;
showmessage('ok');
boo:=true;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
obj_polyline,obj_line,Rectangularpolyline:Variant;
DistBetweenRows, DistBetweenColumns, DistBetweenLevels:double;
NumberOfRows,NumberOfColumns,NumberOfLevels:integer;
fitpoints:Variant;
point1,point2:Variant;
intPoints:Variant; //保存交点
k,i,num:integer;
str:string;
begin
k:=0;
point1:=VarArrayCreate(,VarDouble);
point2:=VarArrayCreate(,VarDouble);
for i:=0 to 5 do
begin
fitpoints:=VarArrayCreate(,VarDouble);
fitpoints:=0+3*i;fitpoints:=0;fitpoints:=0;
fitpoints:=5+3*i;fitpoints:=5;fitpoints:=0;
obj_Polyline:=obj_ModelSpace.AddPolyline(fitpoints);
point1:=i+0.0;point1:=0.0;point1:=0.0;
point2:=i+0.0;point2:=5.0;point2:=0.0;
obj_line:=obj_ModelSpace.Addline(point1,point2);
intPoints:=obj_line.IntersectWith(obj_polyline, 0);
ifVarIsArray(intPoints)then
k:=k+1;
if k<>2 then
obj_line.Delete
else
Exit;
end;
end;
end.红色的代码不能实现,也是问题的关键,有哪位朋友可以帮忙解决下
强烈支持楼主ing…… 真是难得给力的帖子啊。 帮你顶顶吧 大虾看好你 期待你的成果
页:
[1]