89568806 发表于 2008-4-20 16:28:00

[求助]怎么提取多段线的顶点坐标值?

<p>请问各位大侠,能否把当前选择的多段线的顶点坐标值提取出来,并保存在记事本里</p><p></p>

cctv2cctv 发表于 2008-4-20 19:46:00

本帖最后由 作者 于 2008-4-20 19:47:49 编辑 <br /><br /> <pre class="Code">Sub Example_Coordinate()<br/>&nbsp;&nbsp;&nbsp; ' This example creates a polyline in model space and<br/>&nbsp;&nbsp;&nbsp; ' queries and changes the coordinate in the first index position.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim plineObj As AcadPolyline<br/>&nbsp;&nbsp;&nbsp; Dim points(0 To 14) As Double<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' Define the 2D polyline points<br/>&nbsp;&nbsp;&nbsp; points(0) = 1: points(1) = 1: points(2) = 0<br/>&nbsp;&nbsp;&nbsp; points(3) = 1: points(4) = 2: points(5) = 0<br/>&nbsp;&nbsp;&nbsp; points(6) = 2: points(7) = 2: points(8) = 0<br/>&nbsp;&nbsp;&nbsp; points(9) = 3: points(10) = 2: points(11) = 0<br/>&nbsp;&nbsp;&nbsp; points(12) = 4: points(13) = 4: points(14) = 0<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' Create a lightweight Polyline object in model space<br/>&nbsp;&nbsp;&nbsp; Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)<br/>&nbsp;&nbsp;&nbsp; ZoomAll<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' Find the coordinate in the first index position<br/>&nbsp;&nbsp;&nbsp; Dim coord As Variant<br/>&nbsp;&nbsp;&nbsp; coord = plineObj.Coordinate(0)<br/>&nbsp;&nbsp;&nbsp; MsgBox "The coordinate in the first index position of the polyline is: " &amp; coord(0) &amp; ", " _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp; coord(1) &amp; ", " &amp; coord(2)<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' Change the coordinate<br/>&nbsp;&nbsp;&nbsp; coord(0) = coord(0) + 1<br/>&nbsp;&nbsp;&nbsp; plineObj.Coordinate(0) = coord<br/>&nbsp;&nbsp;&nbsp; plineObj.Update<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' Query the new coordinate<br/>&nbsp;&nbsp;&nbsp; coord = plineObj.Coordinate(0)<br/>&nbsp;&nbsp;&nbsp; MsgBox "The coordinate in the first index position of the polyline is now: " &amp; coord(0) &amp; ", " _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp; coord(1) &amp; ", " &amp; coord(2)'<font color="#f73809">这里就是你要的点坐标<br/></font>&nbsp;&nbsp;&nbsp; <br/>End Sub</pre><pre class="Code"><p class="body"></p><p class="body">Open "c:\点坐标.txt" For Output As #1</p><p class="body">Print #1, "你好"</p><p class="body">Print #1, "hello"</p><p class="body">Close #1输出"你好"到txt第一行输出"hello"到txt第二行</p></pre>

89568806 发表于 2008-4-21 08:56:00

太感谢了!!
页: [1]
查看完整版本: [求助]怎么提取多段线的顶点坐标值?