Pt( 0 )= 22
Pt( 1 )= 3
Pt( 2 )= 0
Pt( 3 )= 22
Pt( 4 )= 3
Pt( 5 )= 0
Pt( 6 )= 22
Pt( 7 )= 3
Pt( 8 )= 0目标需求是
p(0),pt(3),pt(6)增加x = 2
p(1),pt(3),pt(7)增加y = 5
p(2),pt(5),pt(8)增加z = 5
For ii = 0 to ubound(Pt)
  ????
Next ii

解决方案 »

  1.   

    For ii = 0 to ubound(Pt) 
        if (ii mod 3)=0 then  Pt(ii)=Pt(ii)+2
        if (ii-1 mod 3)=0 then  Pt(ii)=Pt(ii)+5
        if (ii-2 mod 3)=0 then  Pt(ii)=Pt(ii)+5   
    Next ii 
      

  2.   

    Dim arrTemp(2) As Long
    Dim i&arrTemp(0) = 2
    arrTemp(1) = 5
    arrTemp(2) = 5For i = 0 To UBound(Pt)
        Pt(i) = Pt(i) + arrTemp(i Mod 3)
    Next
      

  3.   

    这比Case方法效果更好
    Sub lls()
      Dim oLeader As AcadLeader, objLeader As AcadLeader
      Dim Pt As Variant, oMtext As AcadMText
      Dim DeltaX, DeltaY
      With ThisDrawing.ModelSpace
        
        Set oLeader = ThisDrawing.HandleToObject("91")
        With oLeader
          x = 5: y = 6
          Pt = .Coordinates
          For ii = 0 To UBound(Pt)
            Select Case ii
              Case 0, 3, 6
                Pt(ii) = Pt(ii) + x
              Case 1, 4, 7
                Pt(ii) = Pt(ii) + y
            End Select
          Next ii
          Set oMtext = .Annotation
            With oMtext
              .InsertionPoint(0) = .InsertionPoint(0) + x
              .InsertionPoint(1) = .InsertionPoint(1) + y
            End With
        End With
        Set objLeader = .AddLeader(Pt, oMtext, acLineWithArrow)
      End With
    End Sub
      

  4.   

    按这个思路,完善的程序
    Sub ls1()
      Dim oLeader As AcadLeader, objLeader As AcadLeader
      Dim Pt As Variant, oMtext As AcadMText
      Dim DeltaX, DeltaY
      Dim arrTemp(2) As Long
      With ThisDrawing.ModelSpace
        
        Set oLeader = ThisDrawing.HandleToObject("91")
        With oLeader
          arrTemp(0) = 5: arrTemp(1) = 6
          Pt = .Coordinates
          For ii = 0 To UBound(Pt)
            Pt(ii) = Pt(ii) + arrTemp(ii Mod 3)
          Next ii
          Set oMtext = .Annotation
            With oMtext
              .InsertionPoint(0) = .InsertionPoint(0) + x
              .InsertionPoint(1) = .InsertionPoint(1) + y
            End With
        End With
        Set objLeader = .AddLeader(Pt, oMtext, acLineWithArrow)
      End With
    End Sub