Offset Method (ActiveX)

Creates a new object at a specified offset distance from an existing object.

Supported platforms: Windows only

Signature

VBA:

RetVal = object.Offset(Distance)
object

Type: Arc, Circle, Ellipse, Line, LWPolyline, Polyline, Spline, XLine

The objects this method applies to.

Distance

Access: Input-only

Type: Double

The distance to offset the object. The offset can be a positive or negative number, but it cannot equal zero. If the offset is negative, this is interpreted as being an offset to make a "smaller" curve (that is, for an arc it would offset to a radius that is "Distance less" than the starting curve's radius). If "smaller" has no meaning, then it would offset in the direction of smaller X, Y, and Z WCS coordinates.

Return Value (RetVal)

Type: Variant (array of objects)

An array of the newly created objects resulting from the offset.

Remarks

For many curves, the result of this operation will be a single new curve (which may not be of the same type as the original curve). For example, offsetting an ellipse will result in a spline because the result does not fit the equation of an ellipse. In some cases it may be necessary for the offset result to be several curves.



An original object and the object with an offset in red.

Examples

VBA:

Sub Example_Offset()
    ' This example creates a lightweight polyline
    ' and then offsets the polyline.
    
    ' Create the polyline
    Dim plineObj As AcadLWPolyline
    Dim points(0 To 11) As Double
    points(0) = 1: points(1) = 1
    points(2) = 1: points(3) = 2
    points(4) = 2: points(5) = 2
    points(6) = 3: points(7) = 2
    points(8) = 4: points(9) = 4
    points(10) = 4: points(11) = 1
    Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
    plineObj.Closed = True
    ZoomAll
            
    MsgBox "Offset the polyline by 0.25.", , "Offset Example"
    
    ' Offset the polyline
    Dim offsetObj As Variant
    offsetObj = plineObj.offset(0.25)
    
    ZoomAll
    MsgBox "Offset completed.", , "Offset Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Offset()
    ;; This example creates a lightweight polyline
    ;; and then offsets the polyline.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Create the polyline
    (setq points (vlax-make-safearray vlax-vbDouble '(0 . 11)))
    (vlax-safearray-fill points '(1 1
                                  1 2
                                  2 2
                                  3 2
                                  4 4
                                  4 1
                                 )
    )

    (setq modelSpace (vla-get-ModelSpace doc))
    (setq plineObj (vla-AddLightWeightPolyline modelSpace points))
    (vla-put-Closed plineObj :vlax-true)
    (vla-ZoomAll acadObj)
            
    (alert "Offset the polyline by 0.25.")
    
    ;; Offset the polyline
    (setq offsetObj (vla-Offset plineObj 0.25))
    
    (vla-ZoomAll acadObj)
    (alert "Offset completed.")
)