The new procedure should be a subroutine because no return value is
required.
5. Click Public under the Scope section.
The new procedure needs to be public so it can be accessed from the
Macros dialog box and outside the code module it is defined in.
6. Click OK in the Add Procedures dialog box.
The new procedure is added to the code window and should look like
this one:
Public Sub DrawLine()
End Sub
C
7. Add this code between the two lines of code that were added by the
Add Procedures dialog box.
Create two variables to hold the points to draw the
line object
Dim dStartPt(0 To 2) As Double, dEndPt(0 To 2) As
Double
Create a Start Point of 0,0,0
dStartPt(0) = 0 X coordinate value
dStartPt(1) = 0 Y coordinate value
dStartPt(2) = 0 Z coordinate value
Create an End Point of 5,5,0
dEndPt(0) = 5: dEndPt(1) = 5: dEndPt(2) = 0
Add the line to Model Space
ThisDrawing.ModelSpace.AddLine dStartPt, dEndPt
8. Click Save on the Standard toolbar in the Visual Basic Editor.
This saves the changes that have been made to the VBA project up to this
point. The DrawLine procedure has now been defined (see Figure 4-15)
and is ready for use in AutoCAD.
igure 4-15:
he
ompleted
rawLine
rocedure.
Tidak ada komentar:
Posting Komentar