明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1157|回复: 1

各位高手,帮我看看这个编程哪里有错误,该怎么改,谢谢了。急救!!

[复制链接]
发表于 2009-9-22 15:29:00 | 显示全部楼层 |阅读模式

这是在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

发表于 2009-9-23 07:55:00 | 显示全部楼层

高度没有赋值

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
height = 5
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

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 00:57 , Processed in 0.155693 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表