乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 54|回复: 1

VBA中的将一段程序编程块的问题

[复制链接]

12

主题

21

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
69
发表于 2015-6-18 09:44:00 | 显示全部楼层 |阅读模式
纯新手,在网上找了很多关于VBA变成块的问题,但是还是不知道怎么操作,还有,就是镜像后的图形能保存快么,下面是我画的图形,不知道怎么写块,求大神指点下,然后我自己琢磨,谢谢各位对新手的指教。
  1. Private Sub CommandButton1_Click()'#############################################################################图幅起始点
  2. Dim x, y, z As Double
  3. '线性添加
  4. Dim entry As AcadLineType
  5. Dim found As Boolean
  6. Dim Itname(0 To 3) As String
  7. Dim i As Integer
  8. found = False
  9. '添加三种线型
  10. Itname(0) = "BORDER"
  11. Itname(1) = "CENTER"
  12. Itname(2) = "DASHDOT"
  13. Itname(3) = "DASHED"
  14. For i = 0 To 3
  15. '搜寻要添加的线型在集合中是否存在
  16. For Each entry In ThisDrawing.Linetypes
  17. If StrComp(entry.Name, Itname(i), 1) = 0 Then
  18. found = True
  19. Exit For
  20. End If
  21. Next
  22. '如果不存在将其从文件acadiso.lin中加载
  23. If Not (found) Then
  24. ThisDrawing.Linetypes.Load Itname(i), "acadiso.lin"
  25. End If
  26. Next
  27. Dim objline(1 To 2000)  As AcadLine
  28. Dim objarc(1 To 2000)  As AcadArc
  29. Dim objcircle(1 To 2000) As AcadCircle
  30. '#############################################################################主视图
  31. Dim zc As Double
  32. x = 1000
  33. y = 1000
  34. z = 0
  35. zc = 0
  36. Dim pt01(2) As Double
  37. Dim pt02(2) As Double
  38. Dim pt03(2) As Double
  39. Dim pt04(2) As Double
  40. Dim pt05(2) As Double
  41. Dim pt06(2) As Double
  42. Dim pt07(2) As Double
  43. Dim pt08(2) As Double
  44. Dim pt09(2) As Double
  45. Dim pt10(2) As Double
  46. Dim pt11(2) As Double
  47. Dim pt12(2) As Double
  48. Dim pt13(2) As Double
  49. Dim pt14(2) As Double
  50. Dim pt15(2) As Double
  51. Dim pt16(2) As Double
  52. Dim pt17(2) As Double
  53. Dim pt18(2) As Double
  54. Dim pt19(2) As Double
  55. Dim pt20(2) As Double
  56. Dim pt95(2) As Double
  57. Dim pt96(2) As Double
  58. pt01(0) = x: pt01(1) = y: pt01(2) = z
  59. pt02(0) = x: pt02(1) = y + 40: pt02(2) = z
  60. pt03(0) = x: pt03(1) = y + 47: pt03(2) = z
  61. pt04(0) = x: pt04(1) = y + 50: pt04(2) = z
  62. pt05(0) = x: pt05(1) = y + 57: pt05(2) = z
  63. pt06(0) = x + 3.3: pt06(1) = y + 57: pt06(2) = z
  64. pt07(0) = x + 3.3: pt07(1) = y + 50: pt07(2) = z
  65. pt08(0) = x + 8.9: pt08(1) = y + 50: pt08(2) = z
  66. pt09(0) = x + 8.9: pt09(1) = y + 47: pt09(2) = z
  67. pt10(0) = x + 40: pt10(1) = y + 47: pt10(2) = z
  68. pt11(0) = x + 40: pt11(1) = y + 40: pt11(2) = z
  69. pt12(0) = x + 90: pt12(1) = y + 40: pt12(2) = z
  70. pt13(0) = x + 90: pt13(1) = y: pt13(2) = z
  71. pt14(0) = x + 4.5: pt14(1) = y + 50: pt14(2) = z
  72. pt15(0) = x + 4.5: pt15(1) = y + 47: pt15(2) = z
  73. pt16(0) = x + 35: pt16(1) = y + 47: pt16(2) = z
  74. pt17(0) = x + 35: pt17(1) = y + 40: pt17(2) = z
  75. pt95(0) = x: pt95(1) = y + 75: pt95(2) = z
  76. pt96(0) = x: pt96(1) = y - zc - 613: pt96(2) = z
  77. Dim objLayer As AcadLayer
  78. Set objLayer = ThisDrawing.Layers.Add("粗实线")
  79. objLayer.color = acWhite
  80. objLayer.Linetype = "Continuous"
  81. objLayer.Lineweight = acLnWt030
  82. ThisDrawing.ActiveLayer = objLayerSet objline(1) = ThisDrawing.ModelSpace.AddLine(pt05, pt06)
  83. Set objline(2) = ThisDrawing.ModelSpace.AddLine(pt06, pt07)
  84. Set objline(3) = ThisDrawing.ModelSpace.AddLine(pt04, pt08)
  85. Set objline(4) = ThisDrawing.ModelSpace.AddLine(pt08, pt09)
  86. Set objline(5) = ThisDrawing.ModelSpace.AddLine(pt03, pt10)
  87. Set objline(6) = ThisDrawing.ModelSpace.AddLine(pt10, pt11)
  88. Set objline(7) = ThisDrawing.ModelSpace.AddLine(pt02, pt12)
  89. Set objline(8) = ThisDrawing.ModelSpace.AddLine(pt12, pt13)
  90. Set objline(9) = ThisDrawing.ModelSpace.AddLine(pt01, pt13)
  91. Set objline(10) = ThisDrawing.ModelSpace.AddLine(pt14, pt15)
  92. Set objline(11) = ThisDrawing.ModelSpace.AddLine(pt16, pt17)
  93. Dim xhcs As Integer
  94. For xhcs = 1 To 11
  95. objline(xhcs).Mirror pt95, pt96
  96. NextEnd Sub

回复

使用道具 举报

0

主题

17

帖子

6

银币

初来乍到

Rank: 1

铜币
17
发表于 2015-6-20 23:28:00 | 显示全部楼层
  1. Private Sub CommandButton1_Click()   '点击按钮_程序
  2. '#############################################################################图幅起始点
  3. Dim x, y, z As Double
  4. '线性添加
  5. Dim entry As AcadLineType  '声明线型
  6. Dim found As Boolean
  7. Dim Itname(0 To 3) As String  '声明数组
  8. Dim i As Integer
  9. found = False
  10. '添加三种线型
  11. Itname(0) = "BORDER"
  12. Itname(1) = "CENTER"
  13. Itname(2) = "DASHDOT"
  14. Itname(3) = "DASHED"
  15. For i = 0 To 3
  16. '搜寻要添加的线型在集合中是否存在
  17. For Each entry In ThisDrawing.Linetypes   '在线型中循环
  18. If StrComp(entry.Name, Itname(i), 1) = 0 Then'如果线型名字为三种的一种
  19. found = True
  20. Exit For  '退出循环
  21. End If
  22. Next
  23. '如果不存在将其从文件acadiso.lin中加载
  24. If Not (found) Then
  25. ThisDrawing.Linetypes.Load Itname(i), "acadiso.lin" '如果不存在自动加载
  26. End If
  27. Next
  28. Dim objline(1 To 2000)  As AcadLine
  29. Dim objarc(1 To 2000)  As AcadArc
  30. Dim objcircle(1 To 2000) As AcadCircle
  31. '#############################################################################主视图Dim zc As Double
  32. x = 1000
  33. y = 1000
  34. z = 0
  35. zc = 0
  36. Dim pt01(2) As Double
  37. Dim pt02(2) As Double
  38. Dim pt03(2) As Double
  39. Dim pt04(2) As Double
  40. [b][b][b][/b][/b][/b]
  41. Dim pt05(2) As Double
  42. Dim pt06(2) As Double
  43. Dim pt07(2) As Double
  44. Dim pt08(2) As Double
  45. Dim pt09(2) As Double
  46. Dim pt10(2) As Double
  47. Dim pt11(2) As Double
  48. Dim pt12(2) As Double
  49. Dim pt13(2) As Double
  50. Dim pt14(2) As Double
  51. Dim pt15(2) As Double
  52. Dim pt16(2) As Double
  53. Dim pt17(2) As Double
  54. Dim pt18(2) As Double
  55. Dim pt19(2) As Double
  56. Dim pt20(2) As Double
  57. Dim pt95(2) As Double
  58. Dim pt96(2) As Double
  59. pt01(0) = x: pt01(1) = y: pt01(2) = z
  60. pt02(0) = x: pt02(1) = y + 40: pt02(2) = z
  61. pt03(0) = x: pt03(1) = y + 47: pt03(2) = z
  62. pt04(0) = x: pt04(1) = y + 50: pt04(2) = z
  63. pt05(0) = x: pt05(1) = y + 57: pt05(2) = z
  64. pt06(0) = x + 3.3: pt06(1) = y + 57: pt06(2) = z
  65. pt07(0) = x + 3.3: pt07(1) = y + 50: pt07(2) = z
  66. pt08(0) = x + 8.9: pt08(1) = y + 50: pt08(2) = z
  67. pt09(0) = x + 8.9: pt09(1) = y + 47: pt09(2) = z
  68. pt10(0) = x + 40: pt10(1) = y + 47: pt10(2) = z
  69. pt11(0) = x + 40: pt11(1) = y + 40: pt11(2) = z
  70. pt12(0) = x + 90: pt12(1) = y + 40: pt12(2) = z
  71. pt13(0) = x + 90: pt13(1) = y: pt13(2) = z
  72. pt14(0) = x + 4.5: pt14(1) = y + 50: pt14(2) = z
  73. pt15(0) = x + 4.5: pt15(1) = y + 47: pt15(2) = z
  74. pt16(0) = x + 35: pt16(1) = y + 47: pt16(2) = z
  75. pt17(0) = x + 35: pt17(1) = y + 40: pt17(2) = z
  76. pt95(0) = x: pt95(1) = y + 75: pt95(2) = z
  77. pt96(0) = x: pt96(1) = y - zc - 613: pt96(2) = z
  78. Dim objLayer As AcadLayer
  79. Set objLayer = ThisDrawing.Layers.Add("粗实线")
  80. objLayer.color = acWhite
  81. objLayer.Linetype = "Continuous"
  82. objLayer.Lineweight = acLnWt030
  83. ThisDrawing.ActiveLayer = objLayer
  84. Set objline(1) = ThisDrawing.ModelSpace.AddLine(pt05, pt06)
  85. Set objline(2) = ThisDrawing.ModelSpace.AddLine(pt06, pt07)
  86. Set objline(3) = ThisDrawing.ModelSpace.AddLine(pt04, pt08)
  87. Set objline(4) = ThisDrawing.ModelSpace.AddLine(pt08, pt09)
  88. Set objline(5) = ThisDrawing.ModelSpace.AddLine(pt03, pt10)
  89. Set objline(6) = ThisDrawing.ModelSpace.AddLine(pt10, pt11)
  90. Set objline(7) = ThisDrawing.ModelSpace.AddLine(pt02, pt12)
  91. Set objline(8) = ThisDrawing.ModelSpace.AddLine(pt12, pt13)
  92. Set objline(9) = ThisDrawing.ModelSpace.AddLine(pt01, pt13)
  93. Set objline(10) = ThisDrawing.ModelSpace.AddLine(pt14, pt15)
  94. Set objline(11) = ThisDrawing.ModelSpace.AddLine(pt16, pt17)
  95. Dim xhcs As Integer
  96. For xhcs = 1 To 11
  97. objline(xhcs).Mirror pt95, pt96
  98. NextEnd Sub
点击按钮名为command_1的按钮即可调用
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-4-20 15:08 , Processed in 2.145927 second(s), 57 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表