VBA在图纸空间中的创建的标注如何与模型关联呢?
<p>用VBA在图纸空间中标注的尺寸标注线型比例是1,而CAD的dli命令会自动修改这个标注线型比例的,用VBA如何自动修改这个标注线型比例呢,或者能得到当前视口的比例系数也可以啊!亲高手们指点。。。</p><p>代码如下:</p><p>Sub dli()<br/> Dim dimObj As AcadDimRotated<br/> Dim p1 As Variant<br/> Dim p2 As Variant<br/> Dim p3 As Variant<br/> Dim rotAngle As Double<br/> Dim rotAngleNunmer As Integer<br/> rotAngleNunmer = 1<br/> With ThisDrawing.Utility<br/> p1 = (.GetPoint(, "请指定标注起始点(按Esc或Enter或左健退出):"))<br/> If IsEmpty(p1) Then Exit Sub<br/> End With<br/> With ThisDrawing.Utility<br/> p2 = (.GetPoint(, "请指定标注结束点(按Esc或Enter或左健退出):"))<br/> If IsEmpty(p2) Then Exit Sub<br/> End With<br/> With ThisDrawing.Utility<br/> p3 = (.GetPoint(, "请指定标注基准点(按Esc或Enter或左健退出):"))<br/> If IsEmpty(p3) Then Exit Sub<br/> End With<br/> On Error Resume Next<br/> If p1(0) < p2(0) Then 'p1点在左边<br/> If p3(0) > p1(0) And p3(0) < p2(0) Then 'p3点X在p1 p2中间<br/> If p3(1) < p1(1) And p3(1) < p2(1) Then 'p3点Y在p1 p2下方<br/> rotAngleNunmer = 1<br/> End If<br/> If p3(1) > p1(1) And p3(1) > p2(1) Then 'p3点Y在p1 p2上方<br/> rotAngleNunmer = 2<br/> End If<br/> End If<br/> End If<br/> If p1(0) > p2(0) Then 'p1点在右边<br/> If p3(0) > p2(0) And p3(0) < p1(0) Then 'p3点X在p1 p2中间<br/> If p3(1) < p1(1) And p3(1) < p2(1) Then 'p3点Y在p1 p2下方<br/> rotAngleNunmer = 1<br/> End If<br/> If p3(1) > p1(1) And p3(1) > p2(1) Then 'p3点Y在p1 p2上方<br/> rotAngleNunmer = 2<br/> End If<br/> End If<br/> End If<br/> If p2(1) > p1(1) Then 'p1点在下边<br/> If p3(1) > p1(1) And p3(1) < p2(1) Then 'p3点y在p1 p2中间<br/> If p3(0) < p1(0) And p3(0) < p2(0) Then 'p3点x在p1 p2左方<br/> rotAngleNunmer = 3<br/> End If<br/> If p3(0) > p1(0) And p3(0) > p2(0) Then 'p3点Y在p1 p2右方<br/> rotAngleNunmer = 4<br/> End If<br/> End If<br/> End If<br/> If p1(1) > p2(1) Then 'p1点在上边<br/> If p3(1) > p2(1) And p3(1) < p1(1) Then 'p3点y在p1 p2中间<br/> If p3(0) < p1(0) And p3(0) < p2(0) Then 'p3点x在p1 p2左方<br/> rotAngleNunmer = 3<br/> End If<br/> If p3(0) > p1(0) And p3(0) > p2(0) Then 'p3点Y在p1 p2右方<br/> rotAngleNunmer = 4<br/> End If<br/> End If<br/> End If<br/> Select Case rotAngleNunmer<br/> Case 1, 2<br/> rotAngle = 0<br/> Case 3, 4<br/> rotAngle = 90<br/> End Select<br/> rotAngle = rotAngle * 3.141592 / 180# ' covert to Radians<br/> If ThisDrawing.ActiveSpace = acPaperSpace Then '当前为图纸空间<br/> Set dimObj = ThisDrawing.PaperSpace.AddDimRotated(p1, p2, p3, rotAngle)<br/> Else<br/> Set dimObj = ThisDrawing.ModelSpace.AddDimRotated(p1, p2, p3, rotAngle)<br/> End If<br/> dimObj.Layer = "标注"<br/> ThisDrawing.SendCommand "dco" & vbCr<br/>End Sub<br/></p>
页:
[1]