VB编程操作AutoCAD半径和直径型尺寸标注
2011-06-18 21:40 精诚所至 金石为开 阅读(933) 评论(0) 编辑 收藏 举报半径或直径型尺寸标注用来标注圆或圆弧,半径或直径型标注的类型与圆或圆弧的大小,TextPosition属性有关也与尺寸标注系统变量DIMUPT、DIMTOFL、DIMTIH、DIMTOH、DIMJUST、DIMTAD的值有关,系统变量用GetVariable和SetVariable方法返回。
创建半径型尺寸标注对象用AddDimRadial方法,语法格式如下。
RetVal=object.AddDimRadial(Center,ChordPoint,LeaderLength)
创建直径型尺寸标注对象用AddDimRadial方法,语法格式如下。
RetVal=object.AddDimDiametric(ChordPoint,FarChordPoint,LeaderLength)
下面的代码创建一个直径型尺寸标注。
Private Sub Command1_Click()
Dim circleobj As AcadCircle
Dim centerpoint(0 To 2) As Double
Dim radius As Double
centerpoint(0) = 10#: centerpoint(1) = 5#: centerpoint(2) = 0#
radius = 5
Set circleobj = acadapp.ActiveDocument.ModelSpace.AddCircle(centerpoint, radius)
Dim dimobj As AcadDimDiametric
Dim chordpoint(0 To 2) As Double
Dim farchordpoint(0 To 2) As Double
Dim leaderlength As Double
chordpoint(0) = 15#: chordpoint(1) = 5#: chordpoint(2) = 0
farchordpoint(0) = 5#: farchordpoint(1) = 5#: farchordpoint(2) = 0#
leaderlength = 1#
Set dimobj = acadapp.ActiveDocument.ModelSpace.AddDimDiametric(chordpoint, farchordpoint, leaderlength)
ZoomExtents
End Sub