Make_SIZE.frm 8.7 KB

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