chonglang 发表于 2005-11-30 03:30:00

关于存储文件的一个小例子(高手指点一下)

<P>源代码</P>
<P>&nbsp;&nbsp;&nbsp; Dim NewObject As AcadDocument<BR>&nbsp;&nbsp;&nbsp; Dim FileName As String<BR>&nbsp;&nbsp;&nbsp; Dim Number As Double<BR>&nbsp;&nbsp;&nbsp; Dim i As Integer<BR>&nbsp;&nbsp;&nbsp; Dim Point1(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim Point2(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim Line As AcadLine<BR>&nbsp;&nbsp;&nbsp; Number = 10<BR>&nbsp;&nbsp;&nbsp; i = 1<BR>&nbsp;&nbsp;&nbsp; Do While i &lt;= Number<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Point1(0) = 0: Point1(1) = 0: Point1(2) = 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Point2(0) = i * 100: Point2(1) = 0: Point2(2) = 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set NewObject = ThisDrawing.Application.Documents.Add<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set Line = ThisDrawing.ModelSpace.AddLine(Point1, Point2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.Application.ZoomExtents<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileName = "D:\" &amp; i &amp; ".dwg"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NewObject.SaveAs FileName<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NewObject.Close False<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = i + 1<BR>&nbsp;&nbsp;&nbsp; Loop<BR>End Sub</P>
<P>我的目的是画一条直线保存一个DWG文件,一共循环10次。为什么运行的时候老是会卡住,就是循环不能真确的完成,请高手指点一下。</P>

王咣生 发表于 2005-11-30 20:29:00

reply

<P>什么时候会卡?我试了一次,运行正常.</P>

chonglang 发表于 2005-11-30 22:47:00

<P>是不是 autocad2004版本的?</P>

王咣生 发表于 2005-11-30 23:00:00

reply

我用的是AutoCAD2004
页: [1]
查看完整版本: 关于存储文件的一个小例子(高手指点一下)