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]