Results 1 to 9 of 9

Thread: Solved: Avoiding the need to rebuild points for ACAD.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Feb 2005
    Posts
    5
    Location

    Solved: HELP! Avoiding the need to rebuild points for ACAD.

    I am more fimilar w/AutoLISP than I am w/VBA in the ACAD environment. So, needless to say AutoLISP usually runs thru my head when I am trying to solve issues in VBA. I want to use the "AddLeader" method to automate adding a leader to my drawing. In my code I prompt the user for (3) three points for the leader using the "GetPoint" method. Then during the draw portion of my code I use the "AddLeader" method to draw the leader. The "AddLeader" needs an array of points which I have pt1, pt2 and pt3. I am seeing so far that it needs me to reconstruct these points from their individual arrays to a larger array that include their collective data. I am finding the only examples and way to do this is to transfer each individual portion of the array to a new slot on the new array called "points". I want to know if I can automate this w/a loop or group the original points in another fashion. All this retyping seems unnecessary????

    This is my code:[VBA]
    'Aquire info for weld symbols
    Private Sub wsuser()
    Dim varRet As Variant
    varRet = ThisDrawing.Utility.GetPoint(, "Leader start point: ")
    pt1(0) = varRet(0)
    pt1(1) = varRet(1)
    pt1(2) = varRet(2)
    varRet = ThisDrawing.Utility.GetPoint(pt1, "Leader second point: ")
    pt2(0) = varRet(0)
    pt2(1) = varRet(1)
    pt2(2) = varRet(2)
    varRet = ThisDrawing.Utility.GetPoint(pt2, "Leader last point: ")
    pt3(0) = varRet(0)
    pt3(1) = varRet(1)
    pt3(2) = varRet(2)
    'MsgBox varRet(0) & ", " & varRet(1) & ", " & varRet(2)
    Dim NoNull As Integer
    NoNull = 1 ' Disallow null
    ThisDrawing.Utility.InitializeUserInput NoNull, "Fillet Groove Plug"
    ThisDrawing.Utility.Prompt "Specify Weld Name "
    wldName = ThisDrawing.Utility.GetKeyword("[Fillet/Groove/Plug]: ")
    ThisDrawing.Utility.InitializeUserInput NoNull, "Field All None Reference Back"
    ThisDrawing.Utility.Prompt "Specify Weld Type "
    wldType = ThisDrawing.Utility.GetKeyword("[Field/All/Reference/Back]: ")
    ThisDrawing.Utility.InitializeUserInput NoNull, "Near Far Both"
    ThisDrawing.Utility.Prompt "Specify Weld Side "
    wldSide = ThisDrawing.Utility.GetKeyword("[Near/Far/Both]: ")
    End Sub
    Sub weldsymbol()
    wsuser
    drwleader
    'MsgBox wldName & " " & wldType & " " & wldSide
    End Sub
    Private Sub drwleader()
    'draws a leader in model space, no annotation
    Dim leaderObj As AcadLeader
    Dim points(0 To 8) As Double
    Dim pt(0 To 2) As Double
    Dim width As Double
    Dim text As String
    Dim leaderType As Integer
    Dim annotationObject As AcadObject

    points(0) = pt1(0): points(1) = pt1(1): points(2) = pt1(2)
    points(3) = pt2(0): points(4) = pt2(1): points(5) = pt2(2)
    points(6) = pt3(0): points(7) = pt3(1): points(8) = pt3(2)

    pt(0) = pt3(0): pt(1) = pt3(1): pt(2) = pt3(2)
    width = 1
    text = "help"
    leaderType = acLineWithArrow
    Set annotationObject = ModelSpace.AddMText(pt, width, wldSide)
    'create the leader object in model space
    Set leaderObj = ThisDrawing.ModelSpace.AddLeader(points, annotationObject, leaderType)
    ZoomAll
    End Sub[/VBA]
    Last edited by dboose; 02-09-2005 at 11:06 AM. Reason: removed excess points array
    DBOOSE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •