AddTrace Method (ActiveX)

Creates a Trace object from an array of points.

Supported platforms: Windows only

Signature

VBA:

RetVal = object.AddTrace(PointsArray)
object

Type: Block, ModelSpace, PaperSpace

The objects this method applies to.

PointsArray

Access: Input-only

Type: Variant (array of doubles)

An array of 3D WCS coordinates specifying the trace endpoints.

Return Value (RetVal)

Type: Trace

The newly created Trace object.

Remarks

The endpoints of a trace are always on the centerline and are always cut square. AutoCAD automatically calculates the correct bevels for connection to adjacent trace segments.

Traces are solid filled when the Fill mode is on. When Fill mode is off, only the outline of a trace appears.

To set the Fill mode, use the AutoCAD FILLMODE system variable. The AutoCAD TRACEWID system variable stores the current width used for Trace objects.

Examples

VBA:

Sub Example_AddTrace()
    ' This example creates a trace in model space.
    
    Dim traceObj As AcadTrace
    Dim tracePts(0 To 11) As Double       ' 4 (3D) points
    
    ' Define the points of the trace
    tracePts(0) = 1: tracePts(1) = 1: tracePts(2) = 0
    tracePts(3) = 3: tracePts(4) = 3: tracePts(5) = 0
    tracePts(6) = 5: tracePts(7) = 3: tracePts(8) = 0
    tracePts(9) = 5: tracePts(10) = 1: tracePts(11) = 0
    
    ' Turn on the system variable (FILLMODE)
    ' to fill the outline of the trace
    ThisDrawing.SetVariable "FILLMODE", 1
        
    ' Create the trace object in model space
    Set traceObj = ThisDrawing.ModelSpace.AddTrace(tracePts)
    ZoomAll
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_AddTrace()
    ;; This example creates a trace in model space.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the points of the trace
    (setq tracePts (vlax-make-safearray vlax-vbDouble '(0 . 11)))
    (vlax-safearray-fill tracePts '(1 1 0
                                    3 3 0
                                    5 3 0
                                    5 1 0
                                   )
    )
    
    ;; Turn on the system variable (FILLMODE)
    ;; to fill the outline of the trace
    (vla-SetVariable doc "FILLMODE" 1)
        
    ;; Create the trace object in model space
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq traceObj (vla-AddTrace modelSpace tracePts))
    (vla-ZoomAll acadObj)
)