A linetype is a repeating pattern of dashes, dots, and blank spaces. A complex linetype is a repeating pattern of symbols. To use a linetype you must first load it into your drawing. A linetype definition must exist in a LIN library file before a linetype can be loaded into a drawing. To load a linetype into your drawing, use the member method LoadLineTypeFile of a Database object.
线型是重复的虚线、点和空格组成的图案。复杂线型则是重复符号的图案。要使用线型,必须先将其加载到图形中。加载之前,LIN 库文件中必须存在该线型的定义。要将线型加载到图形中,请使用 Database 对象的 LoadLineTypeFile 成员方法。
For more information about working with linetypes, see “Overview of Linetypes” in the AutoCAD User's Guide.
有关操作线型的详细信息,请参见《 AutoCAD用户手册》中的“线型概述”。
NoteThe linetypes used internally by AutoCAD should not be confused with the hardware linetypes provided by some plotters. The two types of dashed lines produce similar results. Do not use both types at the same time, however, because the results can be unpredictable.
注意不要将 AutoCAD 内部使用的线型与某些打印机提供的硬件线型相混淆。这两种类型的虚线产生的效果相似。请勿同时使用这两种类型,否则将产生不可预知的结果。
This example 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.
本例试图从 acad.lin 文件中加载线型“CENTER”。如果该线型已存在或者文件不存在,则显示相关消息。
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
<CommandMethod("LoadLinetype")> _
Public Sub LoadLinetype()
'' 获得当前文档和数据库 Get the current document and database
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
''启动一个事务 Start a transaction
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
''以只读方式打开线型表 Open the Linetype table for read
Dim acLineTypTbl As LinetypeTable
acLineTypTbl = acTrans.GetObject(acCurDb.LinetypeTableId, _
OpenMode.ForRead)
Dim sLineTypName As String = "Center"
If acLineTypTbl.Has(sLineTypName) = False Then
''加载中心线型 Load the Center Linetype
acCurDb.LoadLineTypeFile(sLineTypName, "acad.lin")
End If
''保存更改并销毁事务 Save the changes and dispose of the transaction
acTrans.Commit()
End Using
End Sub
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
[CommandMethod("LoadLinetype")]
public static void LoadLinetype()
{
// 获得当前文档和数据库 Get the current document and database
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
// 启动一个事务 Start a transaction
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
// 以只读方式打开线型表 Open the Linetype table for read
LinetypeTable acLineTypTbl;
acLineTypTbl = acTrans.GetObject(acCurDb.LinetypeTableId,
OpenMode.ForRead) as LinetypeTable;
string sLineTypName = "Center";
if (acLineTypTbl.Has(sLineTypName) == false)
{
// Load the Center Linetype
acCurDb.LoadLineTypeFile(sLineTypName, "acad.lin");
}
// Save the changes and dispose of the transaction
acTrans.Commit();
}
}