You can create a leader line from any point or feature in a drawing and control its appearance. Leaders can be straight line segments or smooth spline curves. Leader color is controlled by the current dimension line color. Leader scale is controlled by the overall dimension scale set in the active dimension style. The type and size of the arrowhead, if one is present, is controlled by the arrowhead defined in the active style.
可以从图形中的任意点或特征创建引线,并在绘制时控制其外观。引线可以是直线段或平滑的样条曲线。引线颜色由当前的尺寸线颜色控制。引线缩放比例由活动标注样式中设置的全局标注比例控制。箭头的类型和大小,如果有,由活动样式定义的第一个箭头控制。
A small line known as a hook line usually connects the annotation to the leader. Hook lines appear with multiline text and feature control frames if the last leader line segment is at an angle greater than 15 degrees from horizontal. The hook line is the length of a single arrowhead. If the leader has no annotation, it has no hook line.
注释通常由一条称为基线的小线连接到引线。如果最后一条引线段与水平线的夹角大于 15 度,则基线会与多行文字和特征控制框一起显示。基线具有一个箭头的长度。如果引线没有注释,它也就不会有基线。
You create a leader by creating an instance of a Leader object. When you create an instance of a Leader object, its constructor does not accept any parameters. The AppendVertex method is used to define the position and length of the leader created.
用户通过创建 Leader 对象的实例来创建引线对象。当创建一个引线对象的实例时,它的构造函数不接受任何参数。它的 AppendVertex 方法常常用于定义引线的位置和长度。
This example creates a leader line in model space. There is no annotation associated with the leader line.
本例在模型空间中创建一条引线。引线没有关联的注释。
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
<CommandMethod("CreateLeader")> _
Public Sub CreateLeader()
'' 获得当前数据库 Get the current 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 Block table for read
Dim acBlkTbl As BlockTable
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, _
OpenMode.ForRead)
'' 以写方式打开模型空间块表记录 Open the Block table record Model space for write
Dim acBlkTblRec As BlockTableRecord
acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
OpenMode.ForWrite)
''创建引线 Create the leader
Dim acLdr As Leader = New Leader()
acLdr.SetDatabaseDefaults()
acLdr.AppendVertex(New Point3d(0, 0, 0))
acLdr.AppendVertex(New Point3d(4, 4, 0))
acLdr.AppendVertex(New Point3d(4, 5, 0))
acLdr.HasArrowHead = True
'' 添加新对象到模型空间和事务中 Add the new object to Model space and the transaction
acBlkTblRec.AppendEntity(acLdr)
acTrans.AddNewlyCreatedDBObject(acLdr, True)
'' 提交修改并销毁事务 Commit 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;
using Autodesk.AutoCAD.Geometry;
[CommandMethod("CreateLeader")]
public static void CreateLeader()
{
// 获得当前数据库 Get the current database
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
// 启动一个事务 Start a transaction
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
// 以只读方式打开块表 Open the Block table for read
BlockTable acBlkTbl;
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
OpenMode.ForRead) as BlockTable;
// 以写方式打开模型空间块表记录 Open the Block table record Model space for write
BlockTableRecord acBlkTblRec;
acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],
OpenMode.ForWrite) as BlockTableRecord;
// Create the leader
Leader acLdr = new Leader();
acLdr.SetDatabaseDefaults();
acLdr.AppendVertex(new Point3d(0, 0, 0));
acLdr.AppendVertex(new Point3d(4, 4, 0));
acLdr.AppendVertex(new Point3d(4, 5, 0));
acLdr.HasArrowHead = true;
// 添加新对象到模型空间和事务中 Add the new object to Model space and the transaction
acBlkTblRec.AppendEntity(acLdr);
acTrans.AddNewlyCreatedDBObject(acLdr, true);
// 提交修改并销毁事务 Commit the changes and dispose of the transaction
acTrans.Commit();
}
}