Sub Example_Load() ' This example attempts to load the linetype "CENTER" from ' the acad.lin file. If the linetype already exists, then ' a message is displayed.
Dim linetypeName As String linetypeName = "CENTER"
' Load "CENTER" line type from acad.lin file On Error Resume Next ' trap any load errors ThisDrawing.Linetypes.Load linetypeName, "acad.lin"
' If the name already exists, then notify user If Err.Description = "Duplicate record name" Then MsgBox "A line type named '" & linetypeName & "' already exists.", , "Load Example" End If
''''各位老兄,看看下面的是否合适,以dashed线型为利
Dim i As Integer Dim dashedlineexist As Boolean '''''判断是否存在的标志,如果存在,就激活为当前的线型,否则就添加该线型
dashedlineexist = False ''''先设定其不存在,如果存在就把它设成true
For i = 0 To ThisDrawing.Linetypes.Count - 1 If ThisDrawing.Linetypes.Item(i).Name = "DASHED" Then ThisDrawing.ActiveLinetype = ThisDrawing.Linetypes.Item(i) MsgBox "DASHED线型已经存在" dashedlineexist = True End If Next i
If dashedlineexist = False Then ''''如果不存在就添加
Dim dashedline As AcadLineType ThisDrawing.Linetypes.Load "DASHED", "acad.lin" Set dashedline = ThisDrawing.Linetypes.Item(ThisDrawing.Linetypes.Count - 1) ''''找最后一个