概要 - 線種尺度を指定する(VBA/ActiveX)

作成するオブジェクトの線種尺度を指定できます。

尺度が小さいほど、作図単位ごとに生成されるパターンの繰り返しが多くなります。既定では、AutoCAD はグローバル線種尺度 1.0 (つまり 1 作図単位に等しい尺度)を使用します。すべての図面オブジェクト、属性参照、およびグループについて、線種尺度を変更できます。

線種尺度を変更するには、LinetypeScale プロパティを使用します。

AutoCAD のシステム変数 CELTSCALE は、新しく作成するオブジェクトの線種尺度を設定します。システム変数 LTSCALE は既存オブジェクトと新規オブジェクトの線種尺度をグローバルに変更します。AutoCAD ActiveX オートメーションを使用してシステム変数の値を変更するには、SetVariable メソッドを使用します。

円の線種尺度を変更する

Sub Ch4_ChangeLinetypeScale()
  ' Save the current linetype
  Set currLineType = ThisDrawing.ActiveLinetype

  ' Change the active linetype to Border, so the scale change will
  ' be visible.
  ' First see if the Border linetype is already loaded
  On Error Resume Next          'Turn on error trapping
  ThisDrawing.ActiveLinetype = ThisDrawing.Linetypes.Item("BORDER")
  If Err.Number = -2145386476 Then
    ' Error indicates linetype is not currently loaded, so load it.
    ThisDrawing.Linetypes.Load "BORDER", "acad.lin"
    ThisDrawing.ActiveLinetype = _
          ThisDrawing.Linetypes.Item("BORDER")
  End If

  On Error GoTo 0               ' Turn off error trapping

  ' Create a circle object in model space
  Dim center(0 To 2) As Double
  Dim radius As Double
  Dim circleObj As AcadCircle
  center(0) = 2
  center(1) = 2
  center(2) = 0
  radius = 4
  Set circleObj = ThisDrawing.ModelSpace.AddCircle(center, radius)
  circleObj.Update
  MsgBox ("Here is the circle with the original linetype")

  ' Set the linetype scale of a circle to 3
  circleObj.LinetypeScale = 3#
  circleObj.Update
  MsgBox ("Here is the circle with the new linetype")

  ' Restore original active linetype
  ThisDrawing.ActiveLinetype = currLineType
End Sub