ConstantWidth Property (ActiveX)

Specifies a global width for all segments in a polyline.

Supported platforms: Windows only

Signature

VBA:

object.ConstantWidth
object

Type: LWPolyline, Polyline

The objects this property applies to.

Property Value

Read-only: No

Type: Double

The global width for all segments in the object.

Remarks

This property sets the start and end widths for all segments in a polyline to a uniform value. This property will return a constant width only if all the segments are set to a uniform width.

Use the SetWidth and GetWidth methods to specify the width of an individual segment.

Examples

VBA:

Sub Example_ConstantWidth()
    ' This example creates a lightweight polyline in model space and
    ' uses the ConstantWidth property to determine if the polyline comprises
    ' equal width segments.  If the segments are not equal,
    ' use the ConstantWidth property to set all the segments to the same
    ' width.
    
    Dim plineObj As AcadLWPolyline
    Dim points(0 To 9) As Double
    Dim msg As String, CWidth As Double
    
    ' Define the 2D polyline points
    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
        
    ' Create a lightweight Polyline object in model space
    '
    ' * Note: Return the new PolyLine object into a Module
    ' level variable, which allows events associated
    ' with that particular object to be intercepted.
    Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
    ThisDrawing.Application.ZoomAll
    
    ' Display segment information before altering the width of segment 1
    GoSub DISPLAYSEGMENTS
    
    ' Set the first segment width
    plineObj.SetWidth 1, 0.1, 0.3
    ThisDrawing.Regen acAllViewports
    
    ' Display segment information after altering the width of segment 1
    GoSub DISPLAYSEGMENTS
    
    ' Make all segments uniform in width
    plineObj.ConstantWidth = 0.1
    ThisDrawing.Regen acAllViewports
    
    ' Display segment information after making the segments uniform
    GoSub DISPLAYSEGMENTS
    
    Exit Sub
    
DISPLAYSEGMENTS:
    On Error Resume Next
    
    ' Check to see if the segment widths are uniform
    CWidth = plineObj.ConstantWidth
    
    ' If ConstantWidth returns an error, the
    ' segments are not all the same width
    If Err.Description = "Invalid input" Then
        msg = " are not equal."
    Else
        msg = " are all equal."
    End If
    On Error GoTo 0
    
    MsgBox "The segments of the new polyline" & msg
    
    Return
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_ConstantWidth()
    ;; This example creates a lightweight polyline in model space and
    ;; uses the ConstantWidth property to determine if the polyline comprises
    ;; equal width segments.  If the segments are not equal,
    ;; use the ConstantWidth property to set all the segments to the same
    ;; width.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the 2D polyline points
    (setq points (vlax-make-safearray vlax-vbDouble '(0 . 9)))
    (vlax-safearray-fill points '(1 1
				  1 2
				  2 2
				  3 2
				  4 4
				 )
    )
        
    ;; Create a lightweight Polyline object in model space
    ;;
    ;; * Note: Return the new PolyLine object into a Module
    ;; level variable, which allows events associated
    ;; with that particular object to be intercepted.
    (setq modelSpace (vla-get-ModelSpace doc))   
    (setq plineObj (vla-AddLightWeightPolyline modelSpace points))
    (vla-ZoomAll acadObj)
    
    ;; Display segment information before altering the width of segment 1
    ;; Check to see if the segment widths are uniform
    (setq err (vl-catch-all-apply 'vla-get-ConstantWidth (list plineObj)))
    (if (vl-catch-all-error-p err)
        (setq msg " are not equal.")
        (setq msg " are all equal."
	      CWidth err)
    )
    
    (alert (strcat "The segments of the new polyline" msg))    

    ;; Set the first segment width
    (vla-SetWidth plineObj 1 0.1 0.3)
    (vla-Regen doc acAllViewports)
    
    ;; Display segment information after altering the width of segment 1
    ;; Check to see if the segment widths are uniform
    (setq err (vl-catch-all-apply 'vla-get-ConstantWidth (list plineObj)))
    (if (vl-catch-all-error-p err)
        (setq msg " are not equal.")
        (setq msg " are all equal."
	      CWidth err)
    )
    
    (alert (strcat "The segments of the new polyline" msg))    

    ;; Make all segments uniform in width
    (vla-put-ConstantWidth plineObj 0.1)
    (vla-Regen doc acAllViewports)
    
    ;; Display segment information after making the segments uniform
    ;; Check to see if the segment widths are uniform
    (setq err (vl-catch-all-apply 'vla-get-ConstantWidth (list plineObj)))
    (if (vl-catch-all-error-p err)
        (setq msg " are not equal.")
        (setq msg " are all equal."
	      CWidth err)
    )
    
    (alert (strcat "The segments of the new polyline" msg))
)