📜  AutoCAD Multileader(1)

📅  最后修改于: 2023-12-03 15:13:33.591000             🧑  作者: Mango

AutoCAD Multileader

AutoCAD Multileader is a feature in the AutoCAD software that allows users to create and modify multileaders, which are leader objects that consist of multiple lines of text or symbols with an arrow or dot that points to a feature or object in a drawing.

Features
  • Creation and modification of multileaders with various properties such as text, arrowhead, scale, and line style
  • Multileaders can be added to geometric objects, such as lines, circles, and arcs, or to points in a drawing
  • Multileaders can be manipulated by changing their properties, moving, rotating, or scaling them, or adding new segments
  • Multileaders can be formatted using styles, which can be saved and applied to other multileaders
Benefits
  • Multileaders provide a more efficient way to annotate drawings, as they can display multiple lines of information in one object
  • Multileaders are customizable, allowing users to create annotations that match their company standards or personal preferences
  • Multileaders can be edited and updated easily, saving time and reducing errors
Code Examples

Creating a multileader in AutoCAD using .NET API:

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.EditorInput;

[CommandMethod("Mleader")]
public static void CreateMultileader()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Database db = doc.Database;

    // Specify the first point of the multileader
    PromptPointOptions ppo = new PromptPointOptions("\nSpecify insertion point: ");
    PromptPointResult ppr = doc.Editor.GetPoint(ppo);
    if (ppr.Status != PromptStatus.OK) return;
    Point3d insPt = ppr.Value;

    // Specify the landing line direction
    PromptAngleOptions pao = new PromptAngleOptions("\nSpecify landing line direction: ");
    PromptDoubleResult pdr = doc.Editor.GetAngle(pao);
    if (pdr.Status != PromptStatus.OK) return;
    double angle = pdr.Value;

    // Specify the text content of the multileader
    PromptStringOptions pso = new PromptStringOptions("\nSpecify text: ");
    PromptResult pr = doc.Editor.GetString(pso);
    if (pr.Status != PromptStatus.OK) return;
    string text = pr.StringResult;

    // Create the multileader entity
    using (Transaction tr = db.TransactionManager.StartTransaction())
    {
        BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
        MLeader mleader = new MLeader();
        mleader.Layer = "0";
        mleader.ContentType = ContentType.MTextContent;
        mleader.TextHeight = 2.5;
        mleader.ArrowSize = 1.5;
        mleader.BlockColor = Color.FromRgb(255, 0, 0);
        mleader.BlockScale = 0.8;
        mleader.SetDatabaseDefaults();
        Leader ldr = new Leader();
        ldr.AppendVertex(insPt);
        ldr.AppendVertex(insPt.Add(new Vector3d(Math.Cos(angle), Math.Sin(angle), 0)));
        mleader.DefaultMText = new MText();
        mleader.DefaultMText.Contents = text;
        mleader.DefaultMText.Location = insPt.Add(new Vector3d(2 * Math.Cos(angle), 2 * Math.Sin(angle), 0));
        mleader.DefaultMText.UseVisualStyle = false;
        mleader.Leader = ldr;
        btr.AppendEntity(mleader);
        tr.AddNewlyCreatedDBObject(mleader, true);
        tr.Commit();
    }
}
Conclusion

AutoCAD Multileader is a powerful tool that helps users create and manage annotations in AutoCAD drawings. With its flexible features and easy-to-use interface, it provides an efficient way to annotate drawings and communicate design information.