CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2018 开发者帮助

创建周动半径尺寸 (.NET)

2024-5-18 16:57| 发布者: admin| 查看: 70| 评论: 0|原作者: admin|来自: AutoCAD

创建周动半径尺寸 (.NET)

点动半径尺寸测量对象的半径,并在其前面显示带有半径符号的尺寸文本。在以下情况下,可以在径向尺寸对象上使用轨迹尺寸:

  • 对象的中心点位于布局外部,或者位于模型的某个区域上,该区域没有足够的空间容纳径向尺寸
  • 对象具有较大的半径

通过创建对象的实例来创建周动半径尺寸。创建对象的实例时,其构造函数可以选择接受设置的参数。创建新对象时,可以提供以下参数:RadialDimensionLargeRadialDimensionLargeRadialDimensionLarge

  • 中心点 ( 属性)Center
  • Chord point ( 属性)ChordPoint
  • 覆盖中心点 ( 属性)OverrideCenter
  • 点跑线的位置 ( 属性)JogPoint
  • 点跑线的角度 ( 属性)JogAngle
  • 维度文本(属性)DimensionText
  • 维度样式(或属性)DimensionStyleNameDimensionStyle

创建周动半径尺寸

本示例在模型空间中创建角拐半径尺寸。

VB.NET

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
 
<CommandMethod("CreateJoggedDimension")> _
Public Sub CreateJoggedDimension()
    '' 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 a large radius dimension
        Using acRadDimLrg As RadialDimensionLarge = New RadialDimensionLarge()
            acRadDimLrg.Center = New Point3d(-3, -4, 0)
            acRadDimLrg.ChordPoint = New Point3d(2, 7, 0)
            acRadDimLrg.OverrideCenter = New Point3d(0, 2, 0)
            acRadDimLrg.JogPoint = New Point3d(1, 4.5, 0)
            acRadDimLrg.JogAngle = 0.707
            acRadDimLrg.DimensionStyle = acCurDb.Dimstyle

            '' Add the new object to Model space and the transaction
            acBlkTblRec.AppendEntity(acRadDimLrg)
            acTrans.AddNewlyCreatedDBObject(acRadDimLrg, 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("CreateJoggedDimension")]
public static void CreateJoggedDimension()
{
    // 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 a large radius dimension
        using (RadialDimensionLarge acRadDimLrg = new RadialDimensionLarge())
        {
            acRadDimLrg.Center = new Point3d(-3, -4, 0);
            acRadDimLrg.ChordPoint = new Point3d(2, 7, 0);
            acRadDimLrg.OverrideCenter = new Point3d(0, 2, 0);
            acRadDimLrg.JogPoint = new Point3d(1, 4.5, 0);
            acRadDimLrg.JogAngle = 0.707;
            acRadDimLrg.DimensionStyle = acCurDb.Dimstyle;

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

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

VBA/ActiveX 代码参考

Sub CreateJoggedDimension()
    Dim dimObj As AcadDimRadialLarge
    Dim centerPoint(0 To 2) As Double
    Dim chordPoint(0 To 2) As Double
    Dim centerOverPoint(0 To 2) As Double
    Dim jogPoint(0 To 2) As Double
    Dim jogAngle As Double
 
    ' Define the dimension
    centerPoint(0) = -3: centerPoint(1) = -4: centerPoint(2) = 0
    chordPoint(0) = 2: chordPoint(1) = 7: chordPoint(2) = 0
    centerOverPoint(0) = 0: centerOverPoint(1) = 2: centerOverPoint(2) = 0
    jogPoint(0) = 1: jogPoint(1) = 4.5: jogPoint(2) = 0
    jogAngle = 0.707
 
    ' Create the jogged dimension in Model space
    Set dimObj = ThisDrawing.ModelSpace. _
                     AddDimRadialLarge(centerPoint, chordPoint, _
                                       centerOverPoint, jogPoint, _
                                       jogAngle)
 
    ZoomAll
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-12-15 22:07

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部