ポリラインのすべてのセグメントに対する全体的な幅を指定します。
サポートされているプラットフォーム: Windows のみ
読み込み専用: いいえ
タイプ: 倍精度浮動小数点数型
オブジェクトのすべてのセグメントに対する全体的な幅
このプロパティは、ポリラインのすべてのセグメントの開始幅と終了幅を同一の値に設定します。このプロパティは、すべてのセグメントが同一の幅に設定されている場合に定数幅を戻すだけです。
SetWidth および GetWidth メソッドを使用して個々のセグメントの幅を指定します。
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))
)