CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

创建弧长尺寸 (.NET)

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

弧长尺寸测量沿圆弧的长度,并显示带有弧符号的尺寸文本,该符号位于弧上方或继续上方。当需要标注圆弧的实际长度而不仅仅是其起点和终点之间的距离时,可以使用圆弧长度尺寸。

通过创建对象的实例来创建弧长半径尺寸。创建对象的实例时,它需要一组定义维度的参数。创建新对象时,必须提供以下参数:ArcDimensionArcDimensionArcDimension

  • 中心点 ( 属性)Center
  • 延长线 1 点 ( 属性)XLine1Point
  • 延长线2点(属性)XLine2Point
  • Arc point ( 属性)ArcPoint
  • 维度文本(属性)DimensionText
  • 维度样式(或属性)DimensionStyleNameDimensionStyle
注意:DIMARCSYM 系统变量控制是否显示圆弧符号以及该符号相对于尺寸文本的显示位置。

创建弧长尺寸

本示例在模型空间中创建弧长尺寸。

VB.NET

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
 
<CommandMethod("CreateArcLengthDimension")> _
Public Sub CreateArcLengthDimension()
    '' 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 an arc length dimension
        Using acArcDim As ArcDimension = New ArcDimension(New Point3d(4.5, 1.5, 0), _
                                                          New Point3d(8, 4.25, 0), _
                                                          New Point3d(0, 2, 0), _
                                                          New Point3d(5, 7, 0), _
                                                          "<>", _
                                                          acCurDb.Dimstyle)

            '' Add the new object to Model space and the transaction
            acBlkTblRec.AppendEntity(acArcDim)
            acTrans.AddNewlyCreatedDBObject(acArcDim, 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("CreateArcLengthDimension")]
public static void CreateArcLengthDimension()
{
    // 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 an arc length dimension
        using (ArcDimension acArcDim = new ArcDimension(new Point3d(4.5, 1.5, 0),
                                                        new Point3d(8, 4.25, 0),
                                                        new Point3d(0, 2, 0),
                                                        new Point3d(5, 7, 0),
                                                        "<>",
                                                        acCurDb.Dimstyle))
        {

            // Add the new object to Model space and the transaction
            acBlkTblRec.AppendEntity(acArcDim);
            acTrans.AddNewlyCreatedDBObject(acArcDim, true);
        }

        // Commit the changes and dispose of the transaction
        acTrans.Commit();
    }
}

VBA/ActiveX 代码参考

Sub CreateArcLengthDimension()
    Dim dimObj As AcadDimArcLength
    Dim arcCenterPoint(0 To 2) As Double
    Dim firstPoint(0 To 2) As Double
    Dim secondPoint(0 To 2) As Double
    Dim arcPoint(0 To 2) As Double
 
    ' Define the dimension
    arcCenterPoint(0) = 4.5: arcCenterPoint(1) = 1.5: arcCenterPoint(2) = 0
    firstPoint(0) = 8: firstPoint(1) = 4.25: firstPoint(2) = 0
    secondPoint(0) = 0: secondPoint(1) = 2: secondPoint(2) = 0
    arcPoint(0) = 5: arcPoint(1) = 7: arcPoint(2) = 0
 
    ' Create the arc length dimension in Model space
    Set dimObj = ThisDrawing.ModelSpace. _
                     AddDimArc(arcCenterPoint, firstPoint, _
                     secondPoint, arcPoint)
 
    ZoomAll
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2025-1-8 19:13

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部