Community
Civil 3D Forum
Welcome to Autodesk’s Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VBA to add an arrow

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
1254 Views, 3 Replies

VBA to add an arrow

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?

3 REPLIES 3
Message 2 of 4
MikeEvansUK
in reply to: Anonymous

I do not understand why you want to do this in this way, I think you're making life too hard for yourself.

If you are using Civil3d pipes try adding a leader to a label, if you are specifically using a Line or Polyline try using a modified linetype to include an arrow or > text inside.

You will only need to draw / convert the lines such that they are going downhill. (pedit > reverse or Mirror cmds)

You can easily create custom linetypes with the express tools.

I use this method for my pipework in civil3d and always draw pipes downhill but I also use an label arrow aligned to the slope as a check Expression for rotation is " if ({Pipe Slope}>0,0,pi) "

Mike
Mike Evans

Civil3D 2022 English
Windows 7 Professional 64-bit
Intel(R) Core(TM) i7-3820 CPU @ 3.60GHz (8 CPUs), ~4.0GHz With 32768MB RAM, AMD FirePro V4900, Dedicated Memory: 984 MB, Shared Memory: 814 MB

Message 3 of 4
Anonymous
in reply to: MikeEvansUK

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

Message 4 of 4
MikeEvansUK
in reply to: Anonymous

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

 

Mike Evans

Civil3D 2022 English
Windows 7 Professional 64-bit
Intel(R) Core(TM) i7-3820 CPU @ 3.60GHz (8 CPUs), ~4.0GHz With 32768MB RAM, AMD FirePro V4900, Dedicated Memory: 984 MB, Shared Memory: 814 MB

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report