shirazbj 发表于 2006-3-5 08:44:00

<P>你是用什么画的矩形?</P>
<P>如果是用rectange命令画的,好像不能分别选择各个边。除非你再把那个矩形炸开。</P>
<P>如果是用line画4根线组成的矩形,可以选其中的一条边,然后右键选属性,察看线的起终点。</P>
<P>如果你希望用Vba程序实现,编点程应该可以。下面的例子可以给出图中所有line的起终点。我把所有结果都保存到一个文件里面了。这个例子的前提是你图中所有的元素都是line.这是因为我定义newObjs为AcadLine。 这只是给你点思路以便你实现你所要的功能。</P>
<P>Sub mygetlineinfo()<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp; Dim i, n As Integer<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp; Dim newObjs As AcadLine</P>
<P><BR>&nbsp; Open "c:\myvba\myinfo.txt" For Output As #1<BR>&nbsp; <BR>&nbsp; n = ThisDrawing.ModelSpace.Count<BR>&nbsp; 'MsgBox "N = " &amp; Str(n)<BR>&nbsp; <BR>&nbsp; For i = 0 To n - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set newObjs = ThisDrawing.ModelSpace.Item(i)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Print #1, i<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Print #1, newObjs.StartPoint(iCount), </P>
<P>newObjs.StartPoint(iCount + 1), newObjs.StartPoint(iCount </P>
<P>+ 2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Print #1, newObjs.EndPoint(iCount), </P>
<P>newObjs.EndPoint(iCount + 1), newObjs.EndPoint(iCount + </P>
<P>2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp; Next i<BR>&nbsp; <BR>&nbsp; Close #1<BR>&nbsp; <BR>&nbsp; MsgBox "Good on ya!"<BR>&nbsp;<BR>End Sub</P>
页: 1 [2]
查看完整版本: 如何用vb二次开发“例子.dwg”这样的图。