这是在cad中运用宏,VBA里面编辑的,但是运行老说错误,我想画一个坐标格,然后在最上面标上密度值,请高手帮我改改谢谢 Public Sub kxxqx() Dim L(1 To 2) As AcadLine Dim pnt1(0 To 2) As Double, pnt2(0 To 2) As Double, pnt3(0 To 2) As Double, pnt4(0 To 2) As Double pnt1(0) = 0: pnt1(1) = 0: pnt1(2) = 0 pnt2(0) = 100: pnt2(1) = 0: pnt2(2) = 0 pnt3(0) = 0: pnt3(1) = 0: pnt3(2) = 0 pnt4(0) = 0: pnt4(1) = -100: pnt4(2) = 0 Set L1 = ThisDrawing.ModelSpace.AddLine(pnt1, pnt2) Set L2 = ThisDrawing.ModelSpace.AddLine(pnt3, pnt4) Dim L3 As Variant: Dim L4 As Variant: Dim L5 As Variant: Dim L6 As Variant: Dim L7 As Variant Dim L8 As Variant: Dim L9 As Variant: Dim L10 As Variant: Dim L11 As Variant: Dim L12 As Variant L3 = L1.Offset(-20) L4 = L1.Offset(-40) L5 = L1.Offset(-60) L6 = L1.Offset(-80) L7 = L1.Offset(-100) L8 = L2.Offset(20) L9 = L2.Offset(40) L10 = L2.Offset(60) L11 = L2.Offset(80) L12 = L2.Offset(100) ZoomExtents End Sub Public Sub 标注密度坐标值() Dim den(1 To 7) As AcadText Dim txt(1 To 6) As String Dim inspnt1(0 To 2) As Double: Dim inspnt2(0 To 2) As Double: Dim inspnt3(0 To 2) As Double Dim inspnt4(0 To 2) As Double: Dim inspnt5(0 To 2) As Double: Dim inspnt6(0 To 2) As Double: Dim inspnt7(0 To 2) As Double Dim height As Double txt1 = " 2.2": txt2 = " 2.0": txt3 = " 1.8": txt4 = " 1.6": txt5 = " 1.4": txt6 = " 1.2": txt7 = " 密度" inspnt1(0) = -2: inspnt1(1) = 1: inspnt1(2) = 0 inspnt2(0) = 18: inspnt2(1) = 1: inspnt2(2) = 0 inspnt3(0) = 38: inspnt3(1) = 1: inspnt3(2) = 0 inspnt4(0) = 58: inspnt4(1) = 1: inspnt4(2) = 0 inspnt5(0) = 78: inspnt5(1) = 1: inspnt5(2) = 0 inspnt6(0) = 98: inspnt6(1) = 1: inspnt6(2) = 0 inspnt7(0) = 48: inspnt7(1) = 5: inspnt7(2) = 0 Set den1 = ThisDrawing.ModelSpace.AddText(txt1, inspnt1, height) Set den2 = ThisDrawing.ModelSpace.AddText(txt2, inspnt2, height) Set den3 = ThisDrawing.ModelSpace.AddText(txt3, inspnt3, height) Set den4 = ThisDrawing.ModelSpace.AddText(txt4, inspnt4, height) Set den5 = ThisDrawing.ModelSpace.AddText(txt5, inspnt5, height) Set den6 = ThisDrawing.ModelSpace.AddText(txt6, inspnt6, height) Set den7 = ThisDrawing.ModelSpace.AddText(txt7, inspnt7, height) ZoomExtents End Sub |