tiger0101 发表于 2006-8-8 15:18:00

如何求几根线围成的区域面积

<P>&nbsp;&nbsp; 如何求几根线围成的区域面积</P>
<P>&nbsp;&nbsp; 线可以为Line,或lwLine,曲线</P>
<P>&nbsp; 急求</P>

wyj7485 发表于 2006-8-8 15:35:00

<P>Sub test()<BR>&nbsp;&nbsp;&nbsp; On Error Resume Next<BR><BR>&nbsp;&nbsp;&nbsp; Dim n As Long<BR>&nbsp;&nbsp;&nbsp; n = ThisDrawing.ModelSpace.Count<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim Pt As Variant<BR>Here:<BR>&nbsp;&nbsp;&nbsp; Err = 0<BR>&nbsp;&nbsp;&nbsp; Pt = ThisDrawing.Utility.GetPoint(, "请指定内部点: ")<BR>&nbsp;&nbsp;&nbsp; If Err Then GoTo Here<BR>&nbsp;&nbsp;&nbsp; ThisDrawing.SendCommand "_-Boundary" &amp; vbCr &amp; Pt(0) &amp; "," &amp; Pt(1) &amp; vbCr &amp; vbCr<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR><BR>&nbsp;&nbsp;&nbsp; Dim lwpLineObj As AcadLWPolyline<BR>&nbsp;&nbsp;&nbsp; If ThisDrawing.ModelSpace.Count &gt; n Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set lwpLineObj = ThisDrawing.ModelSpace.Item(ThisDrawing.ModelSpace.Count - 1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msgbox lwpLineObj.area<BR>&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "未发现有效的刃口,请检查可视区域是否闭合.&nbsp;"&nbsp;&nbsp; </P>
<P>End If<BR>End Sub</P>

fjfhgdwfn 发表于 2006-8-8 18:45:00

不错.

tiger0101 发表于 2006-8-22 21:16:00

<P>3ku</P>
<P>写得非常好</P>

arden 发表于 2006-9-9 17:01:00

ThisDrawing.SendCommand "_-Boundary" &amp; vbCr &amp; Pt(0) &amp; "," &amp; Pt(1) &amp; vbCr &amp; vbCr<BR>不知道大家在用这个命令时碰到困难没有,我用起真是头痛,很多时候都不能生成正确的边界(当然不是周围的线没闭合),但是把周围的线一起移到图形的空白地方时同样操作一次基本上又都能生成正确的边界,想不出是什么原因

yuangw1234 发表于 2006-9-10 12:16:00

<P>牛</P>
页: [1]
查看完整版本: 如何求几根线围成的区域面积