[求助]重赋多段线的coordinates值时,CAD报错退出
<p>尝试编了个删除多段线上重复节点的程序,但是最后将新的节点数组NewVert()值赋给多段线的coordinates值,有时可以成功,有时又会报致命错误“Unhandled Access Violation Reading Ox0004 Exception at 6468dfd6h",请教各位大侠这是怎么回事?</p><p>Public Sub DeleteReVertex() '删除多段线相邻的重复节点<br/> Dim Plsl As AcadSelectionSet<br/> Set Plsl = SelectUt.CreateSelectionSet("plsl")<br/> Dim pl As AcadLWPolyline<br/> Dim VerCoords As Variant<br/> Dim IntVertCount As Integer<br/> Dim i As Integer<br/> Dim j As Integer<br/> Dim IntNewVertCount As Integer<br/> Dim NewVert() As Double<br/> Call SelectUt.SelectByFilter(Plsl, acSelectionSetAll, 0, "lwpolyline", 8, "TRY")<br/> For Each pl In Plsl<br/> IntNewVertCount = 0<br/> VerCoords = pl.Coordinates<br/> IntVertCount = (UBound(VerCoords) + 1) / 2<br/> For i = 0 To IntVertCount - 2 '计算新pl的新节点数<br/> If VerCoords(2 * i) <> VerCoords(2 * i + 2) And VerCoords(2 * i + 1) <> VerCoords(2 * i + 3) Then<br/> 'NewVert(j) = VerCoords(2 * i)<br/> 'NewVert(j + 1) = VerCoords(2 * i + 1)<br/> IntNewVertCount = IntNewVertCount + 1<br/> End If<br/> Next i<br/> IntNewVertCount = IntNewVertCount + 1<br/> If IntVertCount <> IntNewVertCount Then '如果有重复点<br/> ReDim NewVert(0 To 2 * IntNewVertCount - 1)<br/> NewVert(2 * IntNewVertCount - 1) = VerCoords(2 * IntVertCount - 1)<br/> NewVert(2 * IntNewVertCount - 2) = VerCoords(2 * IntVertCount - 2)<br/> j = 0<br/> For i = 0 To IntVertCount - 2<br/> If VerCoords(2 * i) <> VerCoords(2 * i + 2) And VerCoords(2 * i + 1) <> VerCoords(2 * i + 3) Then<br/> NewVert(j) = VerCoords(2 * i)<br/> NewVert(j + 1) = VerCoords(2 * i + 1)<br/> j = j + 2<br/> End If<br/> Next i<br/> End If<br/> <font color="#f73809">pl.Coordinates = NewVert 就是这最后一步出错</font><br/> Next<br/>End Sub</p> <p>将pline重画一下就行了</p><p></p> <p>PLine中有扩展数据,重画有点麻烦</p> <p>PLine中有扩展数据,重画有点麻烦</p> <p>那就GetXData,然后SetXData</p> 我觉得是你的算法问题
页:
[1]