kinglau 发表于 2006-3-13 15:58:00

请教如何计算下面图形的长宽

请教如何计算此图形的长宽

kinglau 发表于 2006-3-13 16:01:00

<P></P>
<P>图形如上所示</P>
<P>麻烦指点一下,我编了个程序,就是计算每个图元的起点和终点,然后比较x 和y 坐标,分别取最大和最小值,但是得不到结果~</P>

雪山飞狐_lzh 发表于 2006-3-13 21:42:00

看看这里的GetBoundingBox方法<BR><A href="http://bbs.mjtd.com/forum.php?mod=viewthread&tid=28869" target="_blank" >http://bbs.mjtd.com/forum.php?mod=viewthread&tid=28869</A>

kinglau 发表于 2006-3-14 10:23:00

<P>好象没什么帮助啊?</P>

雪山飞狐_lzh 发表于 2006-3-14 13:02:00

<P>Public Sub tt()<BR>GetBoundingBox d1, d2<BR>MsgBox d2(0) - d1(0) &amp; "," &amp; d2(1) - d1(1)<BR>End Sub</P>
<P>Public Sub GetBoundingBox(ByRef MinPoint, ByRef MaxPoint)<BR>On Error Resume Next</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp; Dim i<BR>&nbsp;&nbsp;&nbsp;&nbsp; Dim d1, d2, p1, p2<BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace(0).GetBoundingBox d1, d2<BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp; For i = 1 To Count - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace(i).GetBoundingBox p1, p2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If p1(0) &lt; d1(0) Then d1(0) = p1(0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If p1(1) &lt; d1(1) Then d1(1) = p1(1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If p2(0) &gt; d2(0) Then d2(0) = p2(0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If p2(1) &gt; d2(1) Then d2(1) = p2(1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp; Next i<BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp; MinPoint = d1<BR>&nbsp;&nbsp;&nbsp;&nbsp; MaxPoint = d2<BR>End Sub<BR></P>

kinglau 发表于 2006-3-14 15:39:00

谢谢,我在看看,呵呵

kinglau 发表于 2006-3-14 20:19:00

非常感谢,其实是个很简单的问题,我犯糊涂了,弄出来了,谢谢了啊
页: [1]
查看完整版本: 请教如何计算下面图形的长宽