mycad 发表于 2005-12-4 15:57:00

再次请教"谁有vba的返回多义线所点击子段的端点坐标程序"

本帖最后由 作者 于 2005-12-11 20:01:10 编辑 <br /><br /> <P>谁有vba的返回多义线所点击子段的端点坐标程序 </P>
<P>斑竹的是vlisp的,</P>
<P>谁有vba的返回多义线所点击子段的端点坐标程序 ,共享学习以下,谢谢了</P>

王咣生 发表于 2005-12-4 18:32:00

reply

<P>多义线的Coordinates属性直接可以得到啊!</P>
<P>帮助中的例子-</P><PRE class=Code>Sub Example_Coordinates()
    ' This example creates a polyline. It then uses the Coordinates
    ' property to return all the coordinatesin the polyline. It then
    ' resets one of the vertices using the Coordinates property.
   
    Dim plineObj As AcadPolyline

    ' Create Polyline
    Dim points(5) As Double
    points(0) = 3: points(1) = 7: points(2) = 0
    points(3) = 9: points(4) = 2: points(5) = 0
    Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)
    ThisDrawing.Regen True

    ' Return all the coordinates of the polyline
    Dim retCoord As Variant
    retCoord = plineObj.Coordinates

    ' Display current coordinates for the first vertex
    MsgBox "The current coordinates of the second vertex are: " &amp; points(3) &amp; ", " &amp; points(4) &amp; ", " &amp; points(5), vbInformation, "Coordinates Example"

    ' Modify the coordinate of the second vertex to (5,5,0). Note that in
    ' case of a lightweight Polyline, indices will be different because the points are 2D only.
    points(3) = 5
    points(4) = 5
    points(5) = 0
    plineObj.Coordinates = points

    ' Update display
    ThisDrawing.Regen True

    MsgBox "The new coordinates have been set to " &amp; points(3) &amp; ", " &amp; points(4) &amp; ", " &amp; points(5), vbInformation, "Coordinates Example"
End Sub</PRE>

mycad 发表于 2005-12-11 17:16:00

<P>谢谢斑竹,我的意思是多段线的有多个"子段",使用鼠标点击其中的一个"子段",使用vba编程显示此"子段"的两对坐标</P>

wyj7485 发表于 2005-12-12 15:35:00

<P>关键是如何获得选中的子段,我是这样处理的:</P>
<P>1,炸开选中的多段线,获得子段集合</P>
<P>2,获得子段集合与选择点距离最近及选择点与子段两端点夹角最大的即是</P>
<P>&nbsp;</P>

tnt1095 发表于 2005-12-12 17:15:00

<P>你可以用对象捕捉的方式捕捉到实体上的点,看它在哪两个点之间。在同一直线上的三个点必然有两个点距离之和等与另两个点的距离,要是不在一直线上呢,就是距离不等了啊</P>
<P>就这就可以判断出在哪两点之间。要再不懂的话我给你发段源代码</P>

mycad 发表于 2005-12-18 10:59:00

<P>谢谢了,楼上的</P>
<P>&nbsp;</P>
页: [1]
查看完整版本: 再次请教"谁有vba的返回多义线所点击子段的端点坐标程序"