明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 761|回复: 0

[运行时] 动态创建多段线错误

[复制链接]
发表于 2015-10-23 21:56 | 显示全部楼层 |阅读模式
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
以上代码只能创建一段,想连续创建要怎么改

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

本版积分规则

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

GMT+8, 2024-3-29 15:32 , Processed in 0.165613 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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