纵坐标或基准尺寸测量从原点(称为基准)到尺寸标注特征(如零件中的孔)的垂直距离。这些尺寸通过保持特征与基准的精确偏移来防止误差的增加。 ![]() 纵坐标尺寸由带有引线的 X 或 Y 纵坐标组成。X 基准纵坐标尺寸用于测量特征沿 X 轴与基准的距离。Y 基准纵坐标尺寸沿 Y 轴测量相同的距离。AutoCAD 使用当前用户坐标系 (UCS) 的原点来确定测量坐标。使用坐标的绝对值。 无论当前尺寸样式定义的方向如何,尺寸文本都与纵坐标引线对齐。您可以接受默认文本,也可以用自己的文本覆盖它。 您可以通过创建对象的实例来创建纵坐标尺寸。创建对象的实例时,其构造函数可以接受一组可选的参数。创建新对象时,可以提供以下参数:OrdinateDimensionOrdinateDimensionOrdinateDimension
将值传递到对象构造函数中时,第一个值是一个布尔标志,用于指定尺寸是 X 基准还是 Y 基准纵坐标尺寸。如果输入 ,则创建 X 基准纵坐标尺寸。如果输入 ,则创建 Y 基准纵坐标尺寸。该属性还可用于指定纵坐标尺寸是 X 基准还是 Y 基准。OrdinateDimensionTRUEFALSEUsingXAxis 创建纵坐标尺寸本示例在模型空间中创建一个纵坐标维。 VB.NETImports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
<CommandMethod("CreateOrdinateDimension")> _
Public Sub CreateOrdinateDimension()
'' 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 ordinate dimension
Using acOrdDim As OrdinateDimension = New OrdinateDimension()
acOrdDim.UsingXAxis = True
acOrdDim.DefiningPoint = New Point3d(5, 5, 0)
acOrdDim.LeaderEndPoint = New Point3d(10, 5, 0)
acOrdDim.DimensionStyle = acCurDb.Dimstyle
'' Add the new object to Model space and the transaction
acBlkTblRec.AppendEntity(acOrdDim)
acTrans.AddNewlyCreatedDBObject(acOrdDim, 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("CreateOrdinateDimension")]
public static void CreateOrdinateDimension()
{
// 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 ordinate dimension
using (OrdinateDimension acOrdDim = new OrdinateDimension())
{
acOrdDim.UsingXAxis = true;
acOrdDim.DefiningPoint = new Point3d(5, 5, 0);
acOrdDim.LeaderEndPoint = new Point3d(10, 5, 0);
acOrdDim.DimensionStyle = acCurDb.Dimstyle;
// Add the new object to Model space and the transaction
acBlkTblRec.AppendEntity(acOrdDim);
acTrans.AddNewlyCreatedDBObject(acOrdDim, true);
}
// Commit the changes and dispose of the transaction
acTrans.Commit();
}
}
VBA/ActiveX 代码参考Sub CreateOrdinateDimension()
Dim dimObj As AcadDimOrdinate
Dim definingPoint(0 To 2) As Double
Dim leaderEndPoint(0 To 2) As Double
Dim useXAxis As Boolean
' Define the dimension
definingPoint(0) = 5
definingPoint(1) = 5
definingPoint(2) = 0
leaderEndPoint(0) = 10
leaderEndPoint(1) = 5
leaderEndPoint(2) = 0
useXAxis = True
' Create an ordinate dimension in model space
Set dimObj = ThisDrawing.ModelSpace. _
AddDimOrdinate(definingPoint, _
leaderEndPoint, useXAxis)
ZoomAll
End Sub
相关概念父主题: |
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 07:08
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.