CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

创建径向尺寸 (.NET)

2023-1-1 11:53| 发布者: admin| 查看: 377| 评论: 0|来自: AutoCAD

径向尺寸测量圆弧和圆的半径和直径。径向和直径尺寸是通过创建 and 对象的实例来创建的。RadialDimensionDiametricDimension

根据圆或弧的大小、尺寸文本的位置以及 DIMUPT、DIMTOFL、DIMFIT、DIMTIH、DIMTOH、DIMJUST 和 DIMTAD 维度系统变量中的值,创建不同类型的径向尺寸。(可以使用 and 方法查询或设置系统变量。GetSystemVariableSetSystemVariable

对于水平尺寸文本,如果尺寸线的角度与水平线的角度超过 15 度,并且位于圆或弧之外,AutoCAD 将绘制一条钩线,也称为着陆线或狗腿线。挂钩线放置在尺寸文本旁边或下方,如下图所示:

创建对象的实例时,可以选择指定中心点和弦点、引线长度、尺寸文本以及要应用的标注样式。创建对象与创建对象类似,不同之处在于指定了弦点和远弦点,而不是中心和弦点。RadialDimensionDiametricDimensionRadialDimension

该属性指定从批注文本到批注文本的距离(如果不需要钩线,则停止)。LeaderLengthChordPoint

创建径向尺寸

本示例在模型空间中创建径向尺寸。

VB.NET

Imports 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

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-19 14:00

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部