CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

替代标注样式 (.NET)

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

每个尺寸都能够覆盖标注样式分配给它的设置。以下属性可用于大多数维度对象:

迪马菲特

指定仅在延长线内显示尺寸线,并强制尺寸文本和箭头在延长线内部或外部显示。

迪马尔特恩德

指定备用单位的舍入。

迪马什

指定尺寸线箭头、引出线箭头和钩线的大小。

二马尼特

指定角度尺寸的单位格式。

Dimblk1, Dimblk2

指定要用于尺寸线箭头的块。

迪姆森

指定径向尺寸和直径尺寸的中心标记的类型和大小。

迪姆克尔德

指定尺寸、引线或公差对象的尺寸线的颜色。

迪姆克莱尔

指定尺寸扩展线的颜色。

迪姆克尔特

指定尺寸和公差对象的文本颜色。

迪姆德克

指定为尺寸或公差的主要单位显示的小数位数。

迪姆塞普

指定要在十进制维度和容差值中用作小数分隔符的字符。

迪梅克斯

指定延长线超出尺寸线的距离。

迪米斯

指定延伸线与原点偏移的距离。

迪姆弗拉克

指定尺寸和公差中分数值的格式。

暗峡

指定在中断尺寸线以容纳尺寸文本时尺寸文本与尺寸线之间的距离。

迪姆法克

指定线性尺寸测量的全局比例因子。

Dimltex1, Dimltex2

指定延伸线的线型。

昏暗

指定尺寸线的线宽。

迪姆尔韦

指定延长线的线宽。

迪姆贾姆

指定尺寸文本的水平对齐。

迪姆恩德

指定尺寸测量的距离舍入。

Dimsd1, Dimsd2

指定尺寸线的隐含。

暗色1, 暗色2

指定延长线的隐含。

迪姆塔德

指定文本相对于尺寸线的垂直位置。

迪姆特克

Specifies the precision of tolerance values in primary dimensions.

Dimtfac

Specifies a scale factor for the text height of tolerance values relative to the dimension text height.

Dimlunit

Specifies the unit format for all dimensions except angular.

Dimtih

Specifies if the dimension text is to be drawn inside the extension lines.

Dimtm

Specifies the minimum tolerance limit for dimension text.

Dimtmove

Specifies how dimension text is drawn when text is moved.

Dimtofl

Specifies if a dimension line is drawn between the extension lines even when the text is placed outside the extension lines.

Dimtoh

Specifies the position of dimension text outside the extension lines for all dimension types except ordinate.

Dimtol

Specifies if tolerances are displayed with the dimension text.

Dimtolj

Specifies the vertical justification of tolerance values relative to the nominal dimension text.

Dimtp

Specifies the maximum tolerance limit for dimension text.

Dimtxt

Specifies the height for the dimension or tolerance text.

Dimzin

Specifies the suppression of leading and trailing zeros, and zero foot and inch measurements in dimension values.

Prefix

Specifies the dimension value prefix.

Suffix

Specifies the dimension value suffix.

TextPrecision

Specifies the precision of angular dimension text.

TextPosition

Specifies the dimension text position.

TextRotation

Specifies the rotation angle of the dimension text.

Enter a user-defined suffix for an aligned dimension

This example creates an aligned dimension in model space and uses the Suffix property to allow the user to change the text suffix for the dimension.

VB.NET

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
 
<CommandMethod("AddDimensionTextSuffix")> _
Public Sub AddDimensionTextSuffix()
    '' 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 aligned dimension
        Using acAliDim As AlignedDimension = New AlignedDimension()
            acAliDim.XLine1Point = New Point3d(0, 5, 0)
            acAliDim.XLine2Point = New Point3d(5, 5, 0)
            acAliDim.DimLinePoint = New Point3d(5, 7, 0)
            acAliDim.DimensionStyle = acCurDb.Dimstyle

            '' Add the new object to Model space and the transaction
            acBlkTblRec.AppendEntity(acAliDim)
            acTrans.AddNewlyCreatedDBObject(acAliDim, True)

            '' Append a suffix to the dimension text
            Dim pStrOpts As PromptStringOptions = New PromptStringOptions("")

            pStrOpts.Message = vbLf & "Enter a new text suffix for the dimension: "
            pStrOpts.AllowSpaces = True
            Dim pStrRes As PromptResult = acDoc.Editor.GetString(pStrOpts)

            If pStrRes.Status = PromptStatus.OK Then
                acAliDim.Suffix = pStrRes.StringResult
            End If
        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.EditorInput;
using Autodesk.AutoCAD.Geometry;
 
[CommandMethod("AddDimensionTextSuffix")]
public static void AddDimensionTextSuffix()
{
    // 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 aligned dimension
        using (AlignedDimension acAliDim = new AlignedDimension())
        {
            acAliDim.XLine1Point = new Point3d(0, 5, 0);
            acAliDim.XLine2Point = new Point3d(5, 5, 0);
            acAliDim.DimLinePoint = new Point3d(5, 7, 0);
            acAliDim.DimensionStyle = acCurDb.Dimstyle;

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

            // Append a suffix to the dimension text
            PromptStringOptions pStrOpts = new PromptStringOptions("");

            pStrOpts.Message = "\nEnter a new text suffix for the dimension: ";
            pStrOpts.AllowSpaces = true;
            PromptResult pStrRes = acDoc.Editor.GetString(pStrOpts);

            if (pStrRes.Status == PromptStatus.OK)
            {
                acAliDim.Suffix = pStrRes.StringResult;
            }
        }

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

VBA/ActiveX 代码参考

Sub AddDimensionTextSuffix()
    Dim dimObj As AcadDimAligned
    Dim point1(0 To 2) As Double
    Dim point2(0 To 2) As Double
    Dim location(0 To 2) As Double
    Dim suffix As String
 
    ' Define the dimension
    point1(0) = 0: point1(1) = 5: point1(2) = 0
    point2(0) = 5: point2(1) = 5: point2(2) = 0
    location(0) = 5: location(1) = 7: location(2) = 0
 
    ' Create an aligned dimension object in model space
    Set dimObj = ThisDrawing.ModelSpace. _
                     AddDimAligned(point1, point2, location)
 
    ThisDrawing.Application.ZoomAll
    ' Allow the user to change the text suffix for the dimension
    suffix = ThisDrawing.Utility. _
                 GetString(True, vbLf & "Enter a new text " & _
                                        "suffix for the dimension: ")
 
    ' Apply the change to the dimension
    dimObj.TextSuffix = suffix
    ThisDrawing.Regen acAllViewports
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-19 12:22

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部