可以从图形中的任何点或要素创建引出线并控制其外观。引线可以是直线段或平滑样条曲线。引线颜色由当前尺寸线颜色控制。引线比例由活动标注样式中的整体尺寸刻度集控制。箭头的类型和大小(如果存在)由活动样式中定义的箭头控制。 一条称为钩线的小线通常将注释连接到引线。如果最后一个引出线段与水平线成大于 15 度的角度,则钩线将显示为多线文本和要素控制框。钩线是单个箭头的长度。如果引线没有注释,则它没有钩线。 您可以通过创建领导者对象的实例来创建领导者。创建 Leader 对象的实例时,其构造函数不接受任何参数。该方法用于定义所创建引线的位置和长度。AppendVertex 创建引导线本示例在模型空间中创建一条引导线。没有与引出线关联的注释。 VB.NETImports 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 Using acLdr As Leader = New Leader() 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) End Using '' Commit the changes and dispose of the transaction acTrans.Commit() End Using End Sub C#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 using (Leader acLdr = new Leader()) { 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(); } } VBA/ActiveX 代码参考Sub CreateLeader() Dim leaderObj As AcadLeader Dim points(0 To 8) As Double Dim leaderType As Integer Dim annotationObject As AcadObject points(0) = 0: points(1) = 0: points(2) = 0 points(3) = 4: points(4) = 4: points(5) = 0 points(6) = 4: points(7) = 5: points(8) = 0 leaderType = acLineWithArrow Set annotationObject = Nothing ' Create the leader object in model space Set leaderObj = ThisDrawing.ModelSpace. _ AddLeader(points, annotationObject, leaderType) ZoomAll End Sub |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )
GMT+8, 2024-5-19 14:27
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.