Specify Linetype Scale

AutoCAD ActiveX

 
Specify Linetype Scale
 
 
 

You can specify the linetype scale for objects you create. The smaller the scale, the more repetitions of the pattern are generated per drawing unit. By default, AutoCAD uses a global linetype scale of 1.0, which is equal to one drawing unit. You can change the linetype scale for all drawing objects, attribute references, and groups.

To change the linetype scale, use the LinetypeScale property.

The CELTSCALE system variable sets the linetype scale for newly created objects. LTSCALE globally changes the linetype scale of existing objects as well as new objects. To change the values of system variables using AutoCAD ActiveX Automation, use the SetVariable method.

For more information about linetype scales, see “Control Linetype Scale” in the User's Guide.

Change the linetype scale for a circle

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