Each dimension has the capability of overriding the settings assigned to it by a dimension style. The following properties are available for most dimension objects:
每个标注都可以替代该标注的标注样式中的设置值。以下特性可用于大多数标注对象:
指定标注线仅仅显示在尺寸界线的内部,并强制标注文字和箭头在尺寸界线的内部或外部。
指定换算单位的舍入。
指定尺寸线箭头、引线箭头和勾线的大小。
指定角度标注的单位格式。
指定用作尺寸线箭头的块。
指定半径标注和直径标注的中心标记大小和类型。
指定标注、引线或公差对象的尺寸线颜色。
指定标注尺寸界线的颜色。
指定标注和公差对象的文字颜色。
指定标注或公差的主单位显示的小数位数。
指定在十进制标注和公差值中用作小数分隔符的字符
指定尺寸界线超出尺寸线的距离。
指定尺寸界线从原点偏移的距离。
指定标注和公差中的分数值的格式。
指定当用户截断尺寸线以放置标注文字时,标注文字与尺寸线之间的距离。
指定线性标注测量值的全局比例因子。
指定尺寸界线的线型。
指定尺寸线的线宽。
指定尺寸界线的线宽。
指定标注文字的水平对正方式。
指定尺寸测量值取整后的距离。
指定是否隐藏尺寸线。
指定是否隐藏尺寸界线。
指定与尺寸线相关联的文字的垂直位置。
指定主标注中公差值的精度。
指定公差值文字高度相对于标注文字高度的比例因子。
指定角度标注除外所有标注的单位格式。
指定是否在尺寸界线之内绘制标注文字。
指定标注文字的最小公差下限。
指定当文字移动时标注文字的绘制方式。
指定所有标注类型(坐标标注除外)的标注文字是否位于尺寸界线之内。
指定所有标注类型(坐标标注除外)的标注文字在尺寸界线之外的位置。
指定公差是否要与标注文字一起显示。
指定公差值相对于标注文字的垂直对正方式
指定标注文字公差的上限。
指定标注或公差文字的高度。
指定是否隐藏标注值中的零英尺和零英寸测量值。
指定标注值的前缀。
指定标注值的后缀。
指定角度标注文字的精度。
指定标注文字的位置。
指定标注文字的旋转角度。
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.
本例在模型空间中创建对齐标注,并使用 Suffix 特性让用户来修改标注的文字后缀。
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
Dim acAliDim As AlignedDimension = New AlignedDimension()
acAliDim.SetDatabaseDefaults()
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
'' 提交修改并销毁事务 Commit the changes and dispose of the transaction
acTrans.Commit()
End Using
End Sub
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
AlignedDimension acAliDim = new AlignedDimension();
acAliDim.SetDatabaseDefaults();
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();
}
}