请问,我可以在delphi中对Autocad2000画出的图进行操作吗?(100分)

  • 主题发起人 主题发起人 高江峰
  • 开始时间 开始时间

高江峰

Unregistered / Unconfirmed
GUEST, unregistred user!
我用Auotocad画了很多图,现在我想用delphi写一个程序,
希望能在程序中调用这些图,并能实现象在Autocad中那样
对图进行放大,缩小和平移,请问用没有这个可能,如果有
的话,我该怎么实现,虚心的等待各位大侠的指导
 
完全可以实现。
你首先需要获取Autocad的文件格式,加在你的Delphi程序中;
至于在Autocad中的一系列画图操作,在Delphi中同样可以实现。
 
应该找一些Delphi控件库,不过不要希望太大,Autocad2000的格式太复杂了,
用Ole吧
 
我做过一点儿CAD的DXF文件的解析,只弄出来几种格式的图形
 
to 卷起千堆雪:
关键是如何获取AutoCAD的文件格式。
可否赐教。
 
Using Delphi with Autocad
Opening and zooming in an Autocad document from a Delphi application
Product:
Delphi 4.x (or higher) Category:
ActiveX Skill Level:
Scoring:
Last Update:
02/05/2001
Search Keys:
delphi delphi3000 article autocad-14 autocad-2000 activex automation Times Scored:
16 Visits:
2508
Uploader: Steven van Els
Company: Staatsolie Refinery Reference: N/A

Question/Problem/Abstract:

I have an Industrial database application in Delphi with several equipment. Also I have a plant layout in Autocad, and several Process Flow Diagrams (PFD) also in Autocad.

How can I show the location of the equipment or the PFD to the users?
Answer:


In this example we let Autocad start up, Open a file and zoom in to a desired location.
We will to this for Acad-14, and Acad-2000


We will need a form with a button, add the units ActiveX, ComObj and OleCtnrs.



unit AcadTest2000


interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ActiveX, ComObj, OleCtnrs


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 : OleVariant

Acad, ActiveDoc, : OleVariant

begin
// create variant arrays to hold coordinates of the window
p1 := VarArrayCreate([0,2], VT_R8)

p2 := VarArrayCreate([0,2], VT_R8)


// assign values to array elements
p1[0] := 14330.0
p1[1] := 400.0
p1[2] := 0
//point (14330,400,0)
p2[0] := 26400.0
p2[1] := 8500.0
p2[2] := 0
//point (26400,8500,0)

Acad := CreateOleObject('AutoCad.Application')

if not varisempty(Acad) then
Acad.visible := visible


// open drawing
ActiveDoc := Acad.Documents.Open('E:/Home/Planview.dwg')


// zoom appliciation
Acad.ZoomExtents

Acad.ZoomWindow(VarArrayRef(p1),VarArrayRef(p2))

end


end.


The Approach for Acad-14 is different. The ZoomExtents and ZoomWindow methods apply to a viewport, also the sintaxe of opening a file is different
unit AcadTest14


interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ActiveX, ComObj, OleCtnrs


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 : OleVariant

Acad, ActiveDoc, ViewPort : OleVariant

begin
// create variant arrays to hold coordinates of the window
p1 := VarArrayCreate([0,2], VT_R8)

p2 := VarArrayCreate([0,2], VT_R8)


// assign values to array elements
p1[0] := 14330.0
p1[1] := 400.0
p1[2] := 0
//point (14330,400,0)
p2[0] := 26400.0
p2[1] := 8500.0
p2[2] := 0
//point (26400,8500,0)

Acad := CreateOleObject('AutoCad.Application.14')

if not varisempty(Acad) then
Acad.visible := visible


// open drawing
ActiveDoc := Acad.ActiveDocument.Open('E:/Home/Planview.dwg')


//Activate viewport
ViewPort := ActiveDoc.ActiveViewPort


// zoom appliciation
ViewPort.ZoomExtents

ViewPort.ZoomWindow(VarArrayRef(p1),VarArrayRef(p2))

end


end.



 
5年前我曾经用Pascal操作过DXF文件
并不是十分复杂,DXF文件中有很多信息你可以不用,而且它是文本文件,读写比较简单
不知道现在的AutoCAD的DXF文件是不是还是这样
又一本蓝色封皮的专门讲Turbo Pascal 4.0-6.0绘图的书,有一章专门讲控制DXF文件
有全套源代码
 
老兄,有位叫汉字库的同志,编写啦关于你说的这种功能的软件,acdsee 1.0
很不错,你可以讨教讨教他
 
谢谢各位大虾的指点,我在www.drdwg.com上找到了一个activeX控件,使用后效果不错,大家如果需要的话,也可以去下载,不过需要先注册一下
 
多人接受答案了。
 
后退
顶部