Change an Object's Linetype

AutoCAD ActiveX

 
Change an Object's Linetype
 
 
 

By default, objects inherit the linetype of the layer on which they are created. To change an object's linetype, use the Linetype property provided for that object. The Linetype property takes the name of the linetype to assign to the object as input.

NoteBefore you can assign a linetype to an object, the linetype must be loaded into the current drawing. To load a linetype into the drawing, use the Load method.

For more information about linetypes, see “Overview of Linetypes” in the User's Guide.

Change the linetype of a circle

This example creates a circle. It then attempts to load the linetype “CENTER” from the acad.lin file. If the linetype already exists, or the file does not exist, then a message is displayed. Finally, it sets the linetype for the circle to be “CENTER.”

Sub Ch4_ChangeCircleLinetype()
    On Error Resume Next
      
    ' Create a circle
    Dim circleObj As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 2: center(1) = 2: center(2) = 0
    radius = 1
    Set circleObj = ThisDrawing.ModelSpace. _
 AddCircle(center, radius)
      
    Dim linetypeName As String
    linetypeName = "CENTER"
      
    ' Load "CENTER" line type from acad.lin file
    ThisDrawing.Linetypes.Load linetypeName, "acad.lin"
    If Err.Description <> "" Then MsgBox Err.Description
      
    ' Assign the circle the linetype "CENTER"
    circleObj.Linetype = "CENTER"
    circleObj.Update
End Sub