[求助]急!!关于获取pline线偏移后的坐标问题
<p>'我想获取pline线偏移后的实体(pline)坐标;下面的代码怎么无法实现呢?</p><p>'请高手赐教,谢谢!!!!!!!</p><p> Sub LinetoBOX2()<br/> Dim returnObj As AcadObject<br/> Dim sset As AcadSelectionSet<br/> Dim COOR As Variant<br/> <br/> Dim CoorL As Variant<br/> Dim CoorR As Variant<br/> <br/> Dim xtype1 As Variant<br/> Dim xdata1 As Variant<br/> <br/> <br/> Dim objPl As AcadPolyline<br/> Dim objPlL As AcadPolyline<br/> Dim objPlR As AcadPolyline<br/> <br/> Dim obj As AcadObject<br/> Dim basepnt As Variant</p><p> Dim offsetObjL As Variant<br/> Dim offsetObjR As Variant<br/> On Error Resume Next<br/> If Not IsNull(ThisDrawing.SelectionSets.Item("this")) Then<br/> Set sset = ThisDrawing.SelectionSets.Item("this")<br/> sset.Delete<br/> End If<br/> <br/> Set sset = ThisDrawing.SelectionSets.Add("this")<br/> <br/> sset.SelectOnScreen<br/> If sset.Count = 0 Then Exit Sub<br/> <br/> Dim s As String<br/> Dim S2 As String<br/> Dim offsetval As Double<br/> For Each obj In sset<br/> MsgBox obj.ObjectName<br/> If obj.ObjectName = "AcDbPolyline" Then<br/> <br/> Set objPl = obj<br/> 'If obj.ConstantWidth > 0 Then<br/> ' offsetval = obj.ConstantWidth<br/> '向左偏移<br/> offsetObjL(0) = objPl.Offset(1.0)<br/> Set objPlL = offsetObjL(0)<br/> CoorL = objPlL.Coordinates<br/> <br/> For i = 0 To UBound(CoorL) 'Step 3<br/> s = s + Format(CoorL(i), "0.000") + "," '+ Format(CoorL(i + 1), "0.000") + Format(CoorL(i + 2), "0.000") + vbCrLf<br/> Next i<br/> '向右偏移<br/> offsetObjR(0) = objPl.Offset(-1.0)<br/> Set objPlR = offsetObjR(0)<br/> <br/> CoorR = objPlR.Coordinates<br/> <br/> For i = 0 To UBound(CoorR) 'Step 3<br/> S2 = S2 + Format(CoorR(i), "0.000") + "," '+ Format(CoorR(i + 1), "0.000") + Format(CoorR(i + 2), "0.000") + vbCrLf<br/> Next i</p><p> MsgBox s + vbCrLf + "*************************************" + vbCrLf + S2<br/> <br/> 'ThisDrawing.SendCommand "huan" & vbCr<br/> 'ThisDrawing.SendCommand "(command " & """huan""" & " "")"</p><p> End If<br/> End If<br/> Next<br/> sset.Clear<br/> <br/> MsgBox "数据处理完毕!", vbInformation<br/> sset.Delete<br/> Exit Sub<br/>line:<br/> MsgBox Err.Description, vbCritical<br/> <br/> End Sub</p> <p> 已解决,谢谢各位 </p><p>把 Dim objPl As AcadPolyline<br/> Dim objPlL As AcadPolyline<br/> Dim objPlR As AcadPolyline<br/>改为</p><p>Dim objPl As AcadLWPolyline</p><p> Dim objPlL As AcadLWPolyline<br/> Dim objPlR As AcadLWPolyline</p><p>即可<br/></p>
页:
[1]