鱼C论坛

 找回密码
 立即注册
查看: 2533|回复: 4

关于delphi对cad二次开发的问题

[复制链接]
发表于 2013-4-19 09:52:12 | 显示全部楼层 |阅读模式
20鱼币
我现在在写一个关于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([0,2],VarDouble);
  point2:=VarArrayCreate([0,2],VarDouble);
  for i:=0 to 5 do
  begin
  fitpoints:=VarArrayCreate([0,5],VarDouble);
  fitpoints[0]:=0+3*i;fitpoints[1]:=0;fitpoints[2]:=0;
  fitpoints[3]:=5+3*i;fitpoints[4]:=5;fitpoints[5]:=0;
  obj_Polyline:=obj_ModelSpace.AddPolyline(fitpoints);
  point1[0]:=i+0.0;point1[1]:=0.0;point1[2]:=0.0;
  point2[0]:=i+0.0;point2[1]:=5.0;point2[2]:=0.0;
  obj_line:=obj_ModelSpace.Addline(point1,point2);
  intPoints:=obj_line.IntersectWith(obj_polyline, 0);
  if  VarIsArray(intPoints)  then
    k:=k+1;
  if k<>2 then
  obj_line.Delete
  else
  Exit;
  end;
end;

end.红色的代码不能实现,也是问题的关键,有哪位朋友可以帮忙解决下

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2013-4-19 19:38:23 | 显示全部楼层
强烈支持楼主ing……
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2013-4-24 23:26:18 | 显示全部楼层
真是难得给力的帖子啊。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2013-4-28 09:24:42 | 显示全部楼层
帮你顶顶吧
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2013-6-11 14:37:11 | 显示全部楼层
大虾  看好你   期待你的成果
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-14 01:59

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表