实习员工
- UID
- 88796
- 积分
- 83
- 金币
-
- 活跃
-
- 阅读权限
- 20
- 注册时间
- 2010-1-2
- 最后登录
- 1970-1-1
|
本帖最后由 linanguyu 于 2010-1-4 09:48 编辑
如何将从excel中读到的坐标值写入autocad,并在autocad该坐标值处写入文本,请高手指教,最好能给我简单的代码,不胜感激
Set layobjp = ThisDrawing.Layers.Add("bevel")
ThisDrawing.ActiveLayer = layobjp
layobjp.color = acGreen
I = 1
z = 0
J = 0
Do Until Cells(I, 1).Value = ""
If Cells(I + 1, 1) = 0 Then
Exit Do
End If
If Left(Cells(I, 1).Value, 10) = "BEVEL_DATA" Then
If Left(Cells(I + 1, 1).Value, 8) = "BEVEL=TS" Then
z = z + 1
str4(z) = "TS" & " " & Mid(Cells(I + 5, 1).Value, 10, 8)
ElseIf Left(Cells(I + 1, 1).Value, 8) = "BEVEL=OS" Then
z = z + 1
str4(z) = "OS" & " " & Mid(Cells(I + 7, 1).Value, 10, 8)
End If
If Mid(Cells(I + 2, 1).Value, 12, 10) = "401.00" Or Mid(Cells(I + 2, 1).Value, 12, 10) = "-401.00" Then
str2(z) = "X"
ElseIf Mid(Cells(I + 2, 1).Value, 12, 10) = "201.00" Or Mid(Cells(I + 2, 1).Value, 12, 10) = "-201.00" Then
str2(z) = "V"
ElseIf Mid(Cells(I + 2, 1).Value, 12, 10) = "306.00" Or Mid(Cells(I + 2, 1).Value, 12, 10) = "-306.00" Then
str2(z) = "Y"
End If
str3(z) = str2(z) & " " & str4(z)
CGx(z) = (Mid(Cells(I + 28, 1).Value, 3, 15) + Mid(Cells(I + 19, 1).Value, 9, 15)) / 2 * Scl + DX
CGy(z) = (Mid(Cells(I + 29, 1).Value, 3, 15) + Mid(Cells(I + 20, 1).Value, 9, 15)) / 2 * Scl + DY '从excel中读入坐标值
End If
I = I + 1
Loop
NN = 0
Do Until Cells(I, 1).Value = ""
If Cells(I + 1, 1) = 0 Then
Exit Do
End If
M = z
N = 1
Do Until M = -1
If Mid(Cells(I + 1, 1).Value, 7, 11) = Mid(str4(N), 4, 8) Then
NN = NN + 1
CGx(1000 + NN) = CGx(N)
CGy(1000 + NN) = CGy(N)
Exit Do
End If
M = M - 1
N = N + 1
Loop
Loop
J = z
K = 1
Do Until J = 0
CG(0) = CGx(1000 + K) - 50
CG(1) = CGy(1000 + K) - 50
CG(2) = 0
Set textObj = ThisDrawing.ModelSpace.AddText(str3(K), CG, 200)
K = K + 1
J = J - 1
Loop |
|