明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1510|回复: 1

[求助]急!!关于获取pline线偏移后的坐标问题

[复制链接]
发表于 2010-5-11 08:50:00 | 显示全部楼层 |阅读模式

'我想获取pline线偏移后的实体(pline)坐标;下面的代码怎么无法实现呢?

'请高手赐教,谢谢!!!!!!!

  Sub LinetoBOX2()
      Dim returnObj As AcadObject
      Dim sset As AcadSelectionSet
      Dim COOR As Variant
     
      Dim CoorL As Variant
      Dim CoorR As Variant
     
      Dim xtype1 As Variant
      Dim xdata1 As Variant
     
   
      Dim objPl As AcadPolyline
      Dim objPlL As AcadPolyline
      Dim objPlR As AcadPolyline
     
      Dim obj As AcadObject
      Dim basepnt As Variant

      Dim offsetObjL As Variant
      Dim offsetObjR As Variant
    On Error Resume Next
      If Not IsNull(ThisDrawing.SelectionSets.Item("this")) Then
        Set sset = ThisDrawing.SelectionSets.Item("this")
        sset.Delete
      End If
     
      Set sset = ThisDrawing.SelectionSets.Add("this")
    
     sset.SelectOnScreen
     If sset.Count = 0 Then Exit Sub
      
      Dim s As String
      Dim S2 As String
      Dim offsetval As Double
    For Each obj In sset
      MsgBox obj.ObjectName
      If obj.ObjectName = "AcDbPolyline" Then
        
                Set objPl = obj
                'If obj.ConstantWidth > 0 Then
               ' offsetval = obj.ConstantWidth
                    '向左偏移
                    offsetObjL(0) = objPl.Offset(1.0)
                    Set objPlL = offsetObjL(0)
                    CoorL = objPlL.Coordinates
                   
                     For i = 0 To UBound(CoorL) 'Step 3
                       s = s + Format(CoorL(i), "0.000") + "," '+ Format(CoorL(i + 1), "0.000") + Format(CoorL(i + 2), "0.000") + vbCrLf
                     Next i
                     '向右偏移
                    offsetObjR(0) = objPl.Offset(-1.0)
                    Set objPlR = offsetObjR(0)
                   
                     CoorR = objPlR.Coordinates
                    
                      For i = 0 To UBound(CoorR) 'Step 3
                       S2 = S2 + Format(CoorR(i), "0.000") + "," '+ Format(CoorR(i + 1), "0.000") + Format(CoorR(i + 2), "0.000") + vbCrLf
                     Next i

                   MsgBox s + vbCrLf + "*************************************" + vbCrLf + S2
                  
                   'ThisDrawing.SendCommand "huan" & vbCr
                   'ThisDrawing.SendCommand "(command " & """huan""" & " "")"

                End If
             End If
         Next
        sset.Clear
       
          MsgBox "数据处理完毕!", vbInformation
          sset.Delete
         Exit Sub
line:
        MsgBox Err.Description, vbCritical
      
  End Sub

 楼主| 发表于 2010-5-11 13:48:00 | 显示全部楼层

  已解决,谢谢各位

把    Dim objPl As AcadPolyline
      Dim objPlL As AcadPolyline
      Dim objPlR As AcadPolyline
改为

Dim objPl As AcadLWPolyline

      Dim objPlL As AcadLWPolyline
      Dim objPlR As AcadLWPolyline

即可

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 22:40 , Processed in 0.141198 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表