Change an Object's Linetype
From AutoCAD ActiveX
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 circleDim circleObj As AcadCircleDim center(0 To 2) As DoubleDim radius As Doublecenter(0) = 2: center(1) = 2: center(2) = 0radius = 1Set circleObj = ThisDrawing.ModelSpace. _AddCircle(center, radius)Dim linetypeName As StringlinetypeName = "CENTER"' Load "CENTER" line type from acad.lin fileThisDrawing.Linetypes.Load linetypeName, "acad.lin"If Err.Description <> "" Then MsgBox Err.Description' Assign the circle the linetype "CENTER"circleObj.Linetype = "CENTER"circleObj.UpdateEnd Sub