创建径向尺寸 (.NET) 
径向尺寸测量圆弧和圆的半径和直径。径向和直径尺寸是通过创建 和 对象的实例来创建的。RadialDimensionDiametricDimension 根据圆或圆弧的大小、尺寸文本的位置以及 DIMUPT、DIMTOFL、DIMFIT、DIMTIH、DIMTOH、DIMJUST和 DIMTAD 尺寸系统变量中的值,将创建不同类型的径向尺寸。(可以使用 and 方法查询或设置系统变量。GetSystemVariableSetSystemVariable 对于水平标注文本,如果标注线的角度与水平方向成 15 度角,并且位于圆或圆弧之外,则 AutoCAD 将绘制一条挂钩线,也称为着陆线或狗腿线。挂钩线位于尺寸文本的旁边或下方,如下图所示: ![]() ![]() 创建对象的实例时,可以选择指定中心点和弦点、引线的长度、尺寸文本以及要应用的尺寸样式。创建对象与对象类似,只不过您指定了和弦点和远弦点,而不是中心和弦点。RadialDimensionDiametricDimensionRadialDimension 该属性指定从批注文本到批注文本的距离(如果不需要挂钩线,则停止)。LeaderLengthChordPoint 创建径向尺寸本示例在模型空间中创建径向尺寸。 VB.NETImports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
 
<CommandMethod("CreateRadialDimension")> _
Public Sub CreateRadialDimension()
    '' 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 radial dimension
        Using acRadDim As RadialDimension = New RadialDimension()
            acRadDim.Center = New Point3d(0, 0, 0)
            acRadDim.ChordPoint = New Point3d(5, 5, 0)
            acRadDim.LeaderLength = 5
            acRadDim.DimensionStyle = acCurDb.Dimstyle
            '' Add the new object to Model space and the transaction
            acBlkTblRec.AppendEntity(acRadDim)
            acTrans.AddNewlyCreatedDBObject(acRadDim, 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("CreateRadialDimension")]
public static void CreateRadialDimension()
{
    // 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 radial dimension
        using (RadialDimension acRadDim = new RadialDimension())
        {
            acRadDim.Center = new Point3d(0, 0, 0);
            acRadDim.ChordPoint = new Point3d(5, 5, 0);
            acRadDim.LeaderLength = 5;
            acRadDim.DimensionStyle = acCurDb.Dimstyle;
            // Add the new object to Model space and the transaction
            acBlkTblRec.AppendEntity(acRadDim);
            acTrans.AddNewlyCreatedDBObject(acRadDim, true);
        }
        // Commit the changes and dispose of the transaction
        acTrans.Commit();
    }
}
VBA/ActiveX 代码参考Sub CreateRadialDimension()
    Dim dimObj As AcadDimRadial
    Dim center(0 To 2) As Double
    Dim chordPoint(0 To 2) As Double
    Dim leaderLen As Integer
 
    ' Define the dimension
    center(0) = 0
    center(1) = 0
    center(2) = 0
    chordPoint(0) = 5
    chordPoint(1) = 5
    chordPoint(2) = 0
    leaderLen = 5
 
    ' Create the radial dimension in model space
    Set dimObj = ThisDrawing.ModelSpace. _
                                  AddDimRadial(center, chordPoint, leaderLen)
    ZoomAll
End Sub
相关概念父主题: | 
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1   苏公网安备32011402011833)
GMT+8, 2025-11-4 14:18
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.