Bryco 发表于 2007-4-12 16:11:52

请在门口检查你的大脑

我今天脑子里放了个大屁 我们今天在工作中遭遇了不幸,我似乎无法让我的大脑思考代码 如果我使用实用程序。GetPoint,我如何使用一段时间或一段时间继续拾取点直到零
Private Sub cmdLayoutLines_Click()
      Me.Hide
      Dim intBusSpacing As Integer, strLayer As AcadLayer, objLine As AcadLine
      Set strLayer = ThisDrawing.Layers.Add("3d-Layout-Lines")
      strLayer.color = 173
      ThisDrawing.ActiveLayer = strLayer
      With ThisDrawing.Utility
            Dim pt1 As Variant, pt2 As Variant
            pt1 = .GetPoint(, "Pick Starting Point: ")
            pt2 = .GetPoint(pt1, "Pick Next Point: ")
            ThisDrawing.ModelSpace.AddLine pt1, pt2
            While pt2Empty
                  pt1 = pt2
                  pt2 = .GetPoint(pt1, "Pick Next Point: ")
                  ThisDrawing.ModelSpace.AddLine pt1, pt2
            Wend
      End With
      Me.Show
End Sub
这不起作用

萝卜扬的后花园 发表于 2007-4-12 16:13:38

出于某种奇怪的原因,在绘制第一行之后,Intellisense告诉我pt2=空,因此检查

北京顽主吧 发表于 2007-4-12 16:18:44

好的,我正在进步Private Sub cmdLayoutLines_Click()
      Me.Hide
      Dim intBusSpacing As Integer, strLayer As AcadLayer, objLine As AcadLine
      Set strLayer = ThisDrawing.Layers.Add("3d-Layout-Lines")
      strLayer.color = 173
      ThisDrawing.ActiveLayer = strLayer
      With ThisDrawing.Utility
            Dim pt1 As Variant, pt2 As Variant
            pt1 = .GetPoint(, "Pick Starting Point: ")
            pt2 = .GetPoint(pt1, "Pick Next Point: ")
            ThisDrawing.ModelSpace.AddLine pt1, pt2
            While Not pt2(0)
                  pt1 = pt2
                  pt2 = .GetPoint(pt1, "Pick Next Point: ")
                  ThisDrawing.ModelSpace.AddLine pt1, pt2
            Wend
      End With
      Me.Show
End Sub 现在它保持拾取点,但在回车键时崩溃

黄花鱼 发表于 2007-4-12 16:23:16


哇!哇!哇 倒车……一场致命的事故&nbsp 什么
此处'这就是我想到的Private Sub cmdLayoutLines_Click()
    Me.Hide
    Dim intBusSpacing As Integer, strLayer As AcadLayer, objLine As AcadLine
    Set strLayer = ThisDrawing.Layers.Add("3d-Layout-Lines")
    strLayer.color = 173
    ThisDrawing.ActiveLayer = strLayer
   
    On Error Resume Next
    Do
      With ThisDrawing.Utility
            Dim pt1 As Variant, pt2 As Variant
            pt1 = .GetPoint(, "Pick Starting Point: ")
            pt2 = .GetPoint(pt1, "Pick Next Point: ")
            ThisDrawing.ModelSpace.AddLine pt1, pt2
            While Not pt2(0)
                pt1 = pt2
                If Err.Number0 Then
                  Exit Do
                Else
                  pt2 = .GetPoint(pt1, "Pick Next Point: ")
                  ThisDrawing.ModelSpace.AddLine pt1, pt2
                End If
            Wend
      End With
    Loop
    Me.Show
End Sub

诛仙图片 发表于 2007-4-12 16:40:07

谢谢马特,我'我来转一圈

小狐狸精 发表于 2007-4-12 23:20:42

这是一种下一步无误恢复的方式
(我使用Randall的autoerrorhandler函数,因此速度很快。
Sub line()
页: [1]
查看完整版本: 请在门口检查你的大脑