26 | 02 | 2017

Create Polyline

 We are going to start by creating a little piece of code to create a simple line object. Open the editor with ALT & F11 and create the following text in the thisdrawing object.
You could see this code as a alternative LINE command. You follow the same steps as when you do this manually. You first provide the start coordinates then the end coordinates and finally you order VBA to place the line between those two tutorials

Sub Createpolyline()
 
'Code from by VisibleVisual
 
Dim Points(0 To 17) As Double
'Define the polyline Coordinates XY, XY, XY .....
Points(0) = 0: Points(1) = 100
Points(2) = 0: Points(3) = 0
Points(4) = 100: Points(5) = 0
Points(6) = 0: Points(7) = 100
Points(8) = 50: Points(9) = 150
Points(10) = 100: Points(11) = 100
Points(12) = 100: Points(13) = 0
Points(14) = 100: Points(15) = 100
 
ThisDrawing.ModelSpace.AddLightWeightPolyline (Points())
 
ZoomAll
 
End Sub

The code above creates the same drawing as show below.


After creating a polyline its possible to continue the code and to add extrusions or subtractions to it. See the tutorial list for more tutorials on this

Download AutoCAD VBA sample below (registered users only:

Login

Sign up now and upload your code to the website.

Help us to continue.....
Statistics
Articles View Hits
2179735
Latest Articles