Hi everyone,
I am a new one to learn how to use vba to draw autocad.
While I am drawing the sewer, I use "addLeader" to add arrow to show the direction of wastewater.
But I find that it shows the line without arrow.
Here is my codes:
Sub sewerdraw()
Dim arrow(609, 22) As Variant
Dim parrow(0 To 5) As Double
Dim leadertype As Integer
Dim leaderobj As AcadLeader
Dim annoation As AcadObject
Dim arrowlayer As AcadLayer
For i = 1 To 609
arrow(i, 2) = Cells(i + 2, 19) 'endpoint x axis
arrow(i, 3) = Cells(i + 2, 20) 'endpoint y axis
arrow(i, 4) = Cells(i + 2, 21) 'startpoint x axis
arrow(i, 5) = Cells(i + 2, 22) 'startpoint y axis
parrow(0) = arrow(i, 4): parrow(1) = arrow(i, 5)
parrow(3) = arrow(i, 2): parrow(4) = arrow(i, 3)
Set arrowlayer = ThisDrawing.Layers.Add("sewer direction")
arrowlayer.color = acCyan
leadertypt = acLineWithArrow
Set annoation = Nothing
If arrow(i, 2) = "" Or arrow(i, 4) = "" Then
Else
Set leaderobj = ThisDrawing.ModelSpace.AddLeader(parrow, annoation, leadertype)
leaderobj.Layer = "sewer direction"
ZoomAll
End If
Next
End sub
The x and y values are Two degree zone transverse mercator projection, something like :
startpoint(196048.835,2508903.016); endpoint(196053.832,2508818073)
Could anyone tell me why there are no arrow, please?
Solved! Go to Solution.
Solved by MikeEvansUK. Go to Solution.
Thanks for reply.
I will use this way to draw my picture because after filed survery I got hundreds even thousands of data. I want to let the program to draw those pictures automaticlly. That is why I need to use VBA program to help me.
Kuang
I would use a block instead of a leader and insert it at the midpoint. Head to the customisation forum.
Dim BLOCKOBJ As AcadBlockReference
BLOCKOBJ = g_oacadDoc.ModelSpace.InsertBlock(varIntPt, VisiBlock, 1.0#, 1.0#, 1.0#, 0)
Function InsertBlock(InsertionPoint As Object, Name As String, Xscale As Double, Yscale As Double, Zscale As Double, Rotation As Double, Optional Password As Object = Nothing) As Autodesk.AutoCAD.Interop.Common.AcadBlockReference
Can't find what you're looking for? Ask the community or share your knowledge.