Make_SIZE.bas 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. VERSION 5.00
  2. Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} Make_SIZE
  3. Caption = " 标注尺寸"
  4. ClientHeight = 1515
  5. ClientLeft = 45
  6. ClientTop = 390
  7. ClientWidth = 3690
  8. OleObjectBlob = "Make_SIZE.frx":0000
  9. StartUpPosition = 1 '所有者中心
  10. End
  11. Attribute VB_Name = "Make_SIZE"
  12. Attribute VB_GlobalNameSpace = False
  13. Attribute VB_Creatable = False
  14. Attribute VB_PredeclaredId = True
  15. Attribute VB_Exposed = False
  16. Private Sub UserForm_Initialize()
  17. With Tis
  18. .BackColor = RGB(0, 150, 255)
  19. .BorderColor = RGB(30, 150, 255)
  20. .ForeColor = RGB(255, 255, 255)
  21. End With
  22. End Sub
  23. Private Function 按钮移入(T)
  24. With T
  25. .BackColor = RGB(0, 150, 255)
  26. .BorderColor = RGB(30, 150, 255)
  27. .ForeColor = RGB(255, 255, 255)
  28. End With
  29. End Function
  30. Private Function 命令按钮(T As Label)
  31. With T
  32. .BackColor = RGB(240, 240, 240)
  33. .BorderColor = RGB(100, 100, 100)
  34. .ForeColor = RGB(0, 0, 0)
  35. End With
  36. End Function
  37. Private Sub CheckBox1_Click()
  38. If CheckBox1 Then CheckBox4 = False
  39. End Sub
  40. Private Sub CheckBox2_Click()
  41. If CheckBox2 Then CheckBox4 = False
  42. End Sub
  43. Private Sub CheckBox3_Click()
  44. If CheckBox3 Then CheckBox1 = False: CheckBox2 = False: CheckBox4 = False
  45. End Sub
  46. Private Sub CheckBox4_Click()
  47. If CheckBox4 Then CheckBox1 = False: CheckBox2 = False: CheckBox3 = False
  48. End Sub
  49. Private Sub Frame1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  50. Call 命令按钮(标注)
  51. Call 命令按钮(删除)
  52. End Sub
  53. Private Sub SpinButton1_SpinDown()
  54. 选中标注字号减少
  55. End Sub
  56. Private Sub SpinButton1_SpinUp()
  57. 选中标注字号增加
  58. End Sub
  59. Private Sub TextBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
  60. 选中标注字号
  61. End Sub
  62. Private Sub 标注_Click()
  63. If CheckBox1 Or CheckBox2 Then Call 标注宽高度
  64. If CheckBox3 Then Call 标注线长
  65. If CheckBox4 Then Call 标注线段长
  66. End Sub
  67. Private Sub 标注_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  68. Call 按钮移入(标注)
  69. End Sub
  70. Private Sub 删除_Click()
  71. 删除标注
  72. End Sub
  73. Private Sub 删除_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  74. Call 按钮移入(删除)
  75. End Sub
  76. Private Sub 标注宽高度()
  77. ActiveDocument.Unit = cdrMillimeter
  78. Dim s As Shape, st1 As Shape, st2 As Shape
  79. Set s = ActiveShape
  80. If s Is Nothing Then Exit Sub
  81. Optimization = True '优化启动
  82. For Each s In ActiveSelection.Shapes
  83. If CheckBox1 Then
  84. Set st1 = ActiveLayer.CreateArtisticText(s.LeftX, s.TopY + 4, round(s.SizeWidth, 0) & "mm", , , "微软雅黑", TextBox1.value, , , , cdrCenterAlignment)
  85. st1.text.Story.CharSpacing = 0 '字符间距
  86. st1.Fill.UniformColor.RGBAssign 40, 170, 20 ' 填充颜色
  87. st1.Move s.SizeWidth / 2, 0
  88. st1.Name = "Text" ' 设置名
  89. Set sox = ActiveLayer.CreateLineSegment(s.LeftX, s.TopY + 3, s.RightX, s.TopY + 3)
  90. sox.Outline.Color.RGBAssign 40, 170, 20 ' 填充颜色
  91. sox.Name = "line"
  92. Set sox1 = ActiveLayer.CreateLineSegment(s.LeftX, s.TopY + 1, s.LeftX, s.TopY + 3)
  93. sox1.Outline.Color.RGBAssign 40, 170, 20 ' 填充颜色
  94. sox1.Name = "line"
  95. Set sox2 = ActiveLayer.CreateLineSegment(s.RightX, s.TopY + 1, s.RightX, s.TopY + 3)
  96. sox2.Outline.Color.RGBAssign 40, 170, 20 ' 填充颜色
  97. sox2.Name = "line"
  98. s.CreateSelection
  99. End If
  100. If CheckBox2 Then
  101. Set st2 = ActiveLayer.CreateArtisticText(s.LeftX - 4, s.BottomY, round(s.SizeHeight, 0) & "mm", , , "微软雅黑", TextBox1.value, , , , cdrCenterAlignment)
  102. st2.text.Story.CharSpacing = 0 '字符间距
  103. st2.Fill.UniformColor.RGBAssign 40, 170, 20 ' 填充颜色
  104. st2.Rotate 90
  105. st2.Move -st2.SizeWidth / 2, s.SizeHeight / 2
  106. st2.Name = "Text" ' 设置名
  107. Set soy = ActiveLayer.CreateLineSegment(s.LeftX - 3, s.BottomY, s.LeftX - 3, s.TopY)
  108. soy.Outline.Color.RGBAssign 40, 170, 20 ' 填充颜色
  109. soy.Name = "line"
  110. Set soy1 = ActiveLayer.CreateLineSegment(s.LeftX - 1, s.BottomY, s.LeftX - 3, s.BottomY)
  111. soy1.Outline.Color.RGBAssign 40, 170, 20 ' 填充颜色
  112. soy1.Name = "line"
  113. Set soy2 = ActiveLayer.CreateLineSegment(s.LeftX - 1, s.TopY, s.LeftX - 3, s.TopY)
  114. soy2.Outline.Color.RGBAssign 40, 170, 20 ' 填充颜色
  115. soy2.Name = "line"
  116. s.CreateSelection
  117. End If
  118. Next
  119. Optimization = False '优化关闭
  120. ActiveWindow.Refresh '刷新文档窗口
  121. End Sub
  122. Private Sub 标注线段长()
  123. ActiveDocument.Unit = cdrMillimeter
  124. Dim s As Shape, s1 As Shape, s2 As Shape, sc As Shape, st1 As Shape, st2 As Shape
  125. Set s = ActiveShape
  126. If s Is Nothing Then Exit Sub
  127. Optimization = True '优化启动
  128. For Each s In ActiveSelection.Shapes
  129. If s.Type <> cdrTextShape Then
  130. s.Copy
  131. Set sc = ActiveLayer.Paste
  132. sc.ConvertToCurves
  133. sc.Curve.Nodes.all.BreakApart
  134. sc.BreakApart
  135. For Each s1 In ActiveSelection.Shapes
  136. Set st1 = ActiveLayer.CreateArtisticText(0, 0, round(s1.Curve.Length, 0), , , , TextBox1.value)
  137. st1.text.Story.CharSpacing = 0 '字符间距
  138. st1.Fill.UniformColor.RGBAssign 40, 170, 20 ' 填充颜色
  139. st1.text.FitToPath s1
  140. ' 获取或设置文本与路径的偏移量
  141. st1.Effects(1).TextOnPath.Offset = s1.Curve.Length * 0.5 - st1.SizeWidth * 0.55
  142. ' 获取或设置文本与路径的距离
  143. st1.Effects(1).TextOnPath.DistanceFromPath = 1
  144. st1.Name = "Text" ' 设置名
  145. s1.Outline.SetNoOutline
  146. s1.OrderToBack
  147. s1.Name = "line"
  148. Next
  149. Set st2 = ActiveLayer.CreateArtisticText(s.RightX + 3, s.BottomY, "单位:mm", , , "微软雅黑", TextBox1.value)
  150. st2.text.Story.CharSpacing = 0 '字符间距
  151. st2.Fill.UniformColor.RGBAssign 40, 170, 20 ' 填充颜色
  152. st2.Name = "Text" ' 设置名
  153. End If
  154. Next
  155. Optimization = False '优化关闭
  156. ActiveWindow.Refresh '刷新文档窗口
  157. End Sub
  158. Private Sub 标注线长()
  159. ActiveDocument.Unit = cdrMillimeter
  160. Dim s As Shape, st1 As Shape
  161. Set s = ActiveShape
  162. If s Is Nothing Then Exit Sub
  163. Optimization = True '优化启动
  164. For Each s In ActiveSelection.Shapes
  165. If s.Type <> cdrTextShape Then
  166. X = s.LeftX
  167. Y = s.BottomY
  168. Set st1 = ActiveLayer.CreateArtisticText(X, Y, "线条长:" & round(s.DisplayCurve.Length, 0) & "mm", , , "微软雅黑", TextBox1.value, , , , cdrLeftAlignment)
  169. st1.text.Story.CharSpacing = 0 '字符间距
  170. st1.Fill.UniformColor.RGBAssign 40, 170, 20 ' 填充颜色
  171. st1.Move 0, -st1.SizeHeight * 2
  172. st1.Name = "Text" ' 设置名
  173. s.CreateSelection
  174. End If
  175. Next
  176. Optimization = False '优化关闭
  177. ActiveWindow.Refresh '刷新文档窗口
  178. End Sub
  179. Private Sub 选中标注字号增加()
  180. Dim s As Shape
  181. Optimization = True '优化启动
  182. If TextBox1.value > 0 Then
  183. TextBox1.value = TextBox1.value + 1
  184. For Each s In ActiveSelection.Shapes.FindShapes(Query:="@type ='text:artistic' and @Name='Text' ")
  185. s.text.Story.size = s.text.Story.size + 1
  186. Next
  187. End If
  188. Optimization = False '优化关闭
  189. ActiveWindow.Refresh '刷新文档窗口
  190. End Sub
  191. Private Sub 选中标注字号减少()
  192. Dim s As Shape
  193. Optimization = True '优化启动
  194. If TextBox1.value > 0 Then
  195. TextBox1.value = TextBox1.value - 1
  196. For Each s In ActiveSelection.Shapes.FindShapes(Query:="@type ='text:artistic' and @Name='Text' ")
  197. s.text.Story.size = s.text.Story.size - 1
  198. Next
  199. End If
  200. Optimization = False '优化关闭
  201. ActiveWindow.Refresh '刷新文档窗口
  202. End Sub
  203. Private Sub 选中标注字号()
  204. Dim s As Shape
  205. Optimization = True '优化启动
  206. If TextBox1.value > 0 Then
  207. For Each s In ActiveSelection.Shapes.FindShapes(Query:="@type ='text:artistic' and @Name='Text' ")
  208. s.text.Story.size = TextBox1.value
  209. Next
  210. End If
  211. Optimization = False '优化关闭
  212. ActiveWindow.Refresh '刷新文档窗口
  213. End Sub
  214. Private Sub 删除标注()
  215. If ActiveSelection.Shapes.Count > 0 Then
  216. ActiveSelection.Shapes.FindShapes(Query:="@type ='text:artistic' and @Name='Text' ").Delete
  217. ActiveSelection.Shapes.FindShapes(Query:="@Name='line' ").Delete
  218. Else
  219. ActivePage.Shapes.FindShapes(Query:="@type ='text:artistic' and @Name='Text' ").Delete
  220. ActivePage.Shapes.FindShapes(Query:="@Name='line' ").Delete
  221. End If
  222. End Sub