CAD学习开发 发表于 2010-4-20 18:33:00

请问Coordinates可以更改一组坐标值吗?(附源码)

<p>请问Coordinates可以更改一组坐标值吗?我看vba帮助里说只能改一个坐标值,但我写了程序怎么能一次改好多坐标值啊?不知道有没有问题</p><p>Sub LWPolyLineCoors()</p><p>&nbsp; On Error Resume Next</p><p>&nbsp; ThisDrawing.SelectionSets("SS1").Delete</p><p>&nbsp; Dim sSet As AcadSelectionSet<br/>&nbsp; Dim objLWPolyLine As AcadLWPolyline<br/>&nbsp; Dim FilterType(0) As Integer<br/>&nbsp; Dim FilterData(0) As Variant<br/>&nbsp; <br/>&nbsp; FilterType(0) = 0<br/>&nbsp; FilterData(0) = "LWPolyLine"</p><p>&nbsp; Set sSet = ThisDrawing.SelectionSets.Add("SS1")<br/>&nbsp; <br/>&nbsp; sSet.SelectOnScreen FilterType, FilterData<br/>&nbsp; <br/>&nbsp; Dim oldCoors As Variant<br/>&nbsp; Dim newCoors As Variant<br/>&nbsp; Dim i As Integer<br/>&nbsp; For Each objLWPolyLine In sSet<br/>&nbsp;&nbsp;&nbsp; oldCoors = objLWPolyLine.Coordinates<br/>&nbsp;&nbsp;&nbsp; For i = 0 To UBound(oldCoors) Step 2<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "原多义线坐标X=" &amp; oldCoors(i) &amp; "&nbsp; Y=" &amp; oldCoors(i + 1)<br/>&nbsp;&nbsp;&nbsp; Next i<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ReDim Preserve oldCoors(7)<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; oldCoors(0) = 0<br/>&nbsp;&nbsp;&nbsp; oldCoors(1) = 0<br/>&nbsp;&nbsp;&nbsp; oldCoors(2) = 1<br/>&nbsp;&nbsp;&nbsp; oldCoors(3) = 1<br/>&nbsp;&nbsp;&nbsp; oldCoors(4) = 2<br/>&nbsp;&nbsp;&nbsp; oldCoors(5) = 2<br/>&nbsp;&nbsp;&nbsp; oldCoors(6) = 1<br/>&nbsp;&nbsp;&nbsp; oldCoors(7) = 0<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; objLWPolyLine.Coordinates = oldCoors<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp; Next objLWPolyLine<br/>&nbsp; <br/>&nbsp; ThisDrawing.Regen True<br/>&nbsp; <br/>&nbsp; sSet.Delete<br/>&nbsp; <br/>End Sub</p>

mccad 发表于 2010-4-20 22:22:00

帮助中已经注明,不能改变顶点数,只能改各点的坐标值

CAD学习开发 发表于 2010-4-21 06:52:00

<p>帮助中说“设置多段线的坐标时,如果用户提供了少于对象当前拥有的坐标数时,多段线将被缩短。任何用于被删除了的顶点上的拟合点也将被删除。如果用户提供了多于对象当前拥有的坐标数时,增加的顶点将被追加到多段线上。”</p><p>这也就是说,如果通过提供多于或少于对象当前拥有的坐标数的方法可以实现顶点数的改变!</p><p>在上面所发的源码里已经得到验证是可行的。</p><p>如果数据中有拟合点可能会有问题!请问mccad我的理解对否?</p>

CAD学习开发 发表于 2010-4-23 20:11:00

怎么没人理会呢??高手给点建议

mccad 发表于 2010-4-23 23:25:00

<p>不好意思,帮助中有自相矛盾的地方。</p><p>确实是可以同时修改多个顶点。</p>
页: [1]
查看完整版本: 请问Coordinates可以更改一组坐标值吗?(附源码)