乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 37|回复: 0

动态创建多段线错误

[复制链接]

1

主题

1

帖子

1

银币

初来乍到

Rank: 1

铜币
5
发表于 2015-10-23 21:56:00 | 显示全部楼层 |阅读模式
Public Sub createpolylinebasic()
'动态创建多段线
   On Error Resume Next
   Dim index As Integer '当前输入点的次数
       index = 2
'提示用户输入第一点
       Dim pt1 As Variant
         pt1 = ThisDrawing.Utility.GetPoint(, "输入第一点:")
            If Err Then    '处理EXc键或者ENTER键的事件
              Err.Clear
              Exit Sub
            End If  
         Dim ptprevious As Variant  '拾取点过程中,存储上一点和当前点的变量
      Dim ptcurrent As Variant      
      ptprevious = pt1   
nextpoint:
              ptcurrent = ThisDrawing.Utility.GetPoint(ptprevious, "输入下一点:")  
                       If Err Then       '处理EXc键或者ENTER键的事件
                       Err.Clear
                       Exit Sub
                    End If   
        Dim objpline As AcadLWPolyline
          If index = 2 Then         
          '创建多段线
                   Dim points(0 To 3) As Double
                     points(0) = ptprevious(0)
                     points(1) = ptprevious(1)
                     points(2) = ptcurrent(0)
                     points(3) = ptcurrent(1)  
                     Set objpiine = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
         ElseIf index > 2 Then
                   Dim ptvert(0 To 1) As Double
                   ptvert(0) = ptcurrent(0)
                   ptvert(1) = ptcurrent(1)
                   objpline.AddVertex index - 1, ptvert                 
        End If
        index = index + 1
        ptprevious = ptcurrent
  GoTo nextpoint     
End Sub
以上代码只能创建一段,想连续创建要怎么改
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-14 13:24 , Processed in 0.356965 second(s), 54 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表