代码改变世界

VB编程操作AutoCAD长度型尺寸标注

2011-06-18 20:59  精诚所至 金石为开  阅读(1203)  评论(0编辑  收藏  举报

长度型尺寸标注包括平行标注与指定角度标注,平行标注的尺寸线平行于尺寸界线起点所在的直线,指定角度标注的尺寸线与尺寸界线起点所在的直线成一定角度。

用AddDimAligned方法创建平行尺寸标注对象,语法格式如下。

RetVal=object.AddDimAligned(ExtLine1Point,ExtLine2Point,TextPosition)

创建指定角度标注对象用AddDimRotated方法,语法格式如下。

RetVal=objcet.AddDimRotated(XLine1Point,XLine2Point,DimLineLocation,RotationAngle)

下面的代码创建并显示一个平行尺寸标注对象。

Private Sub Command1_Click()
    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
    point1(0) = 5#: point1(1) = 5#: point1(2) = 0#
    point2(0) = 28#: point2(1) = 5#: point2(2) = 0#
    location(0) = 10#: location(1) = 15#: location(2) = 10#
    Set lineobj = acadapp.ActiveDocument.ModelSpace.AddLine(point1, point2)
    Set dimobj = acadapp.ActiveDocument.ModelSpace.AddDimAligned(point1, point2, location)
    ZoomExtents
End Sub