Woodman.bas 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. VERSION 5.00
  2. Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} Woodman
  3. Caption = "Woodman标注尺寸节点"
  4. ClientHeight = 1935
  5. ClientLeft = 45
  6. ClientTop = 330
  7. ClientWidth = 3765
  8. OleObjectBlob = "Woodman.frx":0000
  9. StartUpPosition = 1 '所有者中心
  10. End
  11. Attribute VB_Name = "woodman"
  12. Attribute VB_GlobalNameSpace = False
  13. Attribute VB_Creatable = False
  14. Attribute VB_PredeclaredId = True
  15. Attribute VB_Exposed = False
  16. Private Sub btn_square_hi_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  17. ActiveDocument.BeginCommandGroup: Application.Optimization = True
  18. Set os = ActiveSelectionRange
  19. Set ss = os.Shapes
  20. uc = 0
  21. For Each s In ss
  22. s.SizeWidth = s.SizeHeight
  23. uc = uc + 1
  24. Next s
  25. Application.Optimization = False
  26. ActiveWindow.Refresh: Application.Refresh
  27. End Sub
  28. Private Sub btn_square_wi_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  29. ActiveDocument.BeginCommandGroup: Application.Optimization = True
  30. Set os = ActiveSelectionRange
  31. Set ss = os.Shapes
  32. uc = 0
  33. For Each s In ss
  34. s.SizeHeight = s.SizeWidth
  35. uc = uc + 1
  36. Next s
  37. Application.Optimization = False
  38. ActiveWindow.Refresh: Application.Refresh
  39. End Sub
  40. Private Sub btn_makesizes_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  41. Dim os As ShapeRange
  42. Dim s As Shape
  43. Dim sr As ShapeRange
  44. Set doc = ActiveDocument
  45. 'rasm.Dimension.TextShape.Text.Story.size = CLng(fnt)
  46. 'rasm.Style.GetProperty("dimension").SetProperty "precision", 0
  47. 'rasm.Style.GetProperty("dimension").SetProperty "units", 3
  48. doc.BeginCommandGroup "delete sizes"
  49. Set sr = ActiveSelectionRange
  50. sr.RemoveAll
  51. If Shift = 4 Then
  52. On Error Resume Next
  53. Set os = ActiveSelectionRange
  54. For Each s In os.Shapes
  55. If s.Type = cdrLinearDimensionShape Then s.Delete
  56. Next s
  57. On Error GoTo 0
  58. ElseIf Shift = 1 Then
  59. Set os = ActiveSelectionRange
  60. For Each s In os.Shapes
  61. If s.Type = cdrLinearDimensionShape Then sr.Add s
  62. Next s
  63. sr.CreateSelection
  64. On Error GoTo 0
  65. ElseIf Shift = 2 Then
  66. On Error Resume Next
  67. Set os = ActiveSelectionRange
  68. For Each s In os.Shapes
  69. If s.Type = cdrLinearDimensionShape Then s.Delete
  70. Next s
  71. On Error GoTo 0
  72. Else
  73. make_sizes Shift
  74. End If
  75. doc.EndCommandGroup
  76. Application.Refresh
  77. End Sub
  78. Private Sub btn_sizes_up_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  79. make_sizes_sep "up", Shift
  80. End Sub
  81. Private Sub btn_sizes_dn_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  82. make_sizes_sep "dn", Shift
  83. End Sub
  84. Private Sub btn_sizes_lf_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  85. make_sizes_sep "lf", Shift
  86. End Sub
  87. Private Sub btn_sizes_ri_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  88. make_sizes_sep "ri", Shift
  89. End Sub
  90. Private Sub btn_sizes_btw_up_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  91. make_sizes_sep "upb", Shift
  92. End Sub
  93. Private Sub btn_sizes_btw_dn_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  94. make_sizes_sep "dnb", Shift
  95. End Sub
  96. Private Sub btn_sizes_btw_lf_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  97. make_sizes_sep "lfb", Shift
  98. End Sub
  99. Private Sub btn_sizes_btw_ri_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  100. make_sizes_sep "rib", Shift
  101. End Sub
  102. Sub make_sizes_sep(dr, Optional shft = 0)
  103. Set doc = ActiveDocument
  104. Dim s As Shape
  105. Dim pts As New SnapPoint, pte As New SnapPoint
  106. Dim os As ShapeRange
  107. un = doc.Unit
  108. doc.Unit = cdrMillimeter
  109. doc.BeginCommandGroup "make sizes"
  110. Set os = ActiveSelectionRange
  111. If dr = "upb" Or dr = "dnb" Or dr = "up" Or dr = "dn" Then os.Sort "@shape1.left < @shape2.left"
  112. If dr = "lfb" Or dr = "rib" Or dr = "lf" Or dr = "ri" Then os.Sort "@shape1.top > @shape2.top"
  113. If os.Count > 0 Then
  114. If os.Count > 1 And Len(dr) > 2 Then
  115. For I = 1 To os.Shapes.Count - 1
  116. Select Case dr
  117. Case "upb":
  118. Set pts = os.Shapes(I).SnapPoints.BBox(cdrTopRight)
  119. Set pte = os.Shapes(I + 1).SnapPoints.BBox(cdrTopLeft)
  120. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, os.LeftX + os.SizeWidth / 10, os.TopY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  121. Case "dnb":
  122. Set pts = os.Shapes(I).SnapPoints.BBox(cdrBottomRight)
  123. Set pte = os.Shapes(I + 1).SnapPoints.BBox(cdrBottomLeft)
  124. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, os.LeftX + os.SizeWidth / 10, os.BottomY - os.SizeHeight / 10, cdrDimensionStyleEngineering
  125. Case "lfb":
  126. Set pts = os.Shapes(I).SnapPoints.BBox(cdrBottomLeft)
  127. Set pte = os.Shapes(I + 1).SnapPoints.BBox(cdrTopLeft)
  128. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, os.LeftX - os.SizeWidth / 10, os.BottomY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  129. Case "rib":
  130. Set pts = os.Shapes(I).SnapPoints.BBox(cdrBottomRight)
  131. Set pte = os.Shapes(I + 1).SnapPoints.BBox(cdrTopRight)
  132. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, os.RightX + os.SizeWidth / 10, os.BottomY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  133. End Select
  134. 'ActiveDocument.ClearSelection
  135. Next I
  136. Else
  137. If shft > 0 Then
  138. Select Case dr
  139. Case "up":
  140. Set pts = os.FirstShape.SnapPoints.BBox(cdrTopLeft)
  141. Set pte = os.LastShape.SnapPoints.BBox(cdrTopRight)
  142. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, os.LeftX + os.SizeWidth / 10, os.TopY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  143. Case "dn":
  144. Set pts = os.FirstShape.SnapPoints.BBox(cdrBottomLeft)
  145. Set pte = os.LastShape.SnapPoints.BBox(cdrBottomRight)
  146. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, os.LeftX + os.SizeWidth / 10, os.BottomY - os.SizeHeight / 10, cdrDimensionStyleEngineering
  147. Case "lf":
  148. Set pts = os.FirstShape.SnapPoints.BBox(cdrTopLeft)
  149. Set pte = os.LastShape.SnapPoints.BBox(cdrBottomLeft)
  150. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, os.LeftX - os.SizeWidth / 10, os.BottomY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  151. Case "ri":
  152. Set pts = os.FirstShape.SnapPoints.BBox(cdrTopRight)
  153. Set pte = os.LastShape.SnapPoints.BBox(cdrBottomRight)
  154. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, os.RightX + os.SizeWidth / 10, os.BottomY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  155. End Select
  156. Else
  157. For Each s In os.Shapes
  158. Select Case dr
  159. Case "up":
  160. Set pts = s.SnapPoints.BBox(cdrTopLeft)
  161. Set pte = s.SnapPoints.BBox(cdrTopRight)
  162. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, s.LeftX + s.SizeWidth / 10, s.TopY + s.SizeHeight / 10, cdrDimensionStyleEngineering
  163. Case "dn":
  164. Set pts = s.SnapPoints.BBox(cdrBottomLeft)
  165. Set pte = s.SnapPoints.BBox(cdrBottomRight)
  166. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, s.LeftX + s.SizeWidth / 10, s.BottomY - s.SizeHeight / 10, cdrDimensionStyleEngineering
  167. Case "lf":
  168. Set pts = s.SnapPoints.BBox(cdrTopLeft)
  169. Set pte = s.SnapPoints.BBox(cdrBottomLeft)
  170. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, s.LeftX - s.SizeWidth / 10, s.BottomY + s.SizeHeight / 10, cdrDimensionStyleEngineering
  171. Case "ri":
  172. Set pts = s.SnapPoints.BBox(cdrTopRight)
  173. Set pte = s.SnapPoints.BBox(cdrBottomRight)
  174. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, s.RightX + s.SizeWidth / 10, s.BottomY + s.SizeHeight / 10, cdrDimensionStyleEngineering
  175. End Select
  176. Next s
  177. End If
  178. End If
  179. End If
  180. os.CreateSelection
  181. doc.EndCommandGroup
  182. doc.Unit = un
  183. End Sub
  184. Sub make_sizes(Optional shft = 0)
  185. Set doc = ActiveDocument
  186. Dim s As Shape
  187. Dim pts As SnapPoint, pte As SnapPoint
  188. Dim os As ShapeRange
  189. un = doc.Unit
  190. doc.Unit = cdrMillimeter
  191. doc.BeginCommandGroup "make sizes"
  192. Set os = ActiveSelectionRange
  193. If os.Count > 0 Then
  194. For Each s In os.Shapes
  195. Set pts = s.SnapPoints.BBox(cdrTopLeft)
  196. Set pte = s.SnapPoints.BBox(cdrTopRight)
  197. Set ptle = s.SnapPoints.BBox(cdrBottomLeft)
  198. If shft <> 6 Then ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, ptle, True, s.LeftX - s.SizeWidth / 10, s.BottomY + s.SizeHeight / 10, cdrDimensionStyleEngineering
  199. If shft <> 3 Then ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, s.LeftX + s.SizeWidth / 10, s.TopY + s.SizeHeight / 10, cdrDimensionStyleEngineering
  200. Next s
  201. End If
  202. doc.EndCommandGroup
  203. doc.Unit = un
  204. End Sub
  205. Public Function make_selection(Optional mode = "fcolor", Optional sel = True, Optional OSS As ShapeRange = Nothing, Optional colr = Nothing) As ShapeRange
  206. Dim s As Shape, lst As Shape
  207. Dim sr As ShapeRange
  208. 'Dim os As ShapeRange
  209. Set doc = ActiveDocument
  210. doc.Unit = cdrTenthMicron
  211. If OSS Is Nothing Then
  212. If toolspanel.num_list.value Or mode = "locked" Then
  213. Set os = ActivePage
  214. Else
  215. Set os = ActiveSelectionRange
  216. End If
  217. Else
  218. Set os = OSS
  219. End If
  220. Set sr = ActiveSelectionRange
  221. sr.RemoveAll
  222. If sel Then ActiveDocument.ClearSelection
  223. Set lst = os.Shapes.First
  224. For Each s In os.Shapes
  225. Select Case mode
  226. Case "ocolor": If s.Outline.Type <> cdrNoOutline And s.Shapes.Count = 0 And s.Outline.Color.HexValue = colr.HexValue Then sr.Add s
  227. Case "fcolor": If s.Fill.Type <> cdrNoFill And s.Shapes.Count = 0 And s.Fill.UniformColor.HexValue = colr.HexValue Then sr.Add s
  228. Case "nofil": If s.Fill.Type = cdrNoFill And s.Shapes.Count = 0 Then sr.Add s
  229. Case "fil": If s.Fill.Type <> cdrNoFill And s.Shapes.Count = 0 Then sr.Add s
  230. Case "abr": If s.Outline.Type <> cdrNoOutline And s.Shapes.Count = 0 Then sr.Add s
  231. Case "noabr": If s.Outline.Type = cdrNoOutline And s.Shapes.Count = 0 Then sr.Add s
  232. Case "open": If Not s.DisplayCurve Is Nothing Then If Not s.DisplayCurve.Closed Then sr.Add s
  233. Case "closed": If Not s.DisplayCurve Is Nothing Then If s.DisplayCurve.Closed Then sr.Add s
  234. Case "single": If s.Shapes.Count = 0 Then sr.Add s
  235. Case "dashed": If s.Outline.Style.DashCount > 0 Then sr.Add s
  236. Case "groups": If s.Shapes.Count > 0 And s.Effect Is Nothing Then sr.Add s
  237. Case "text": If s.Shapes.Count = 0 And s.Type = cdrTextShape Then sr.Add s
  238. Case "notext": If s.Shapes.Count = 0 And s.Type <> cdrTextShape Then sr.Add s
  239. Case "images": If s.Type = cdrBitmapShape Then sr.Add s
  240. Case "locked": If s.Locked Then sr.Add s
  241. Case "effects": If s.Effects.Count > 0 Or Not s.Effect Is Nothing Then sr.Add s
  242. Case "noeffects": If s.Effects.Count = 0 And s.Effect Is Nothing Then sr.Add s
  243. Case "bigger":
  244. arelst = lst.SizeHeight * lst.SizeWidth
  245. ares = s.SizeHeight * s.SizeWidth
  246. If ares >= arelst Then
  247. are = one_shape_area(lst)
  248. If one_shape_area(s) >= are Then sr.Add s
  249. End If
  250. Case "smaller":
  251. arelst = lst.SizeHeight * lst.SizeWidth
  252. ares = s.SizeHeight * s.SizeWidth
  253. If ares <= arelst Then
  254. are = one_shape_area(lst)
  255. If one_shape_area(s) <= are Then sr.Add s
  256. End If
  257. Case "last":
  258. If lst.Fill.Type = cdrNoFill Then
  259. 's.CreateSelection
  260. If s.Outline.Type <> cdrNoOutline Then If s.Outline.Color.HexValue = lst.Outline.Color.HexValue Then sr.Add s
  261. Else
  262. If s.Fill.UniformColor.HexValue = lst.Fill.UniformColor.HexValue Then sr.Add s
  263. End If
  264. End Select
  265. Next s
  266. If sr.Shapes.Count > 0 And sel Then sr.CreateSelection
  267. Set make_selection = sr
  268. Application.Refresh
  269. ActiveWindow.Activate
  270. End Function
  271. Public Function get_events(btn As String, Optional shft = 0, Optional click = 1)
  272. out = "ok"
  273. get_events = out
  274. End Function
  275. Private Sub btn_join_nodes_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  276. ActiveSelection.CustomCommand "ConvertTo", "JoinCurves"
  277. Application.Refresh
  278. End Sub
  279. Private Sub btn_nodes_reduce_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  280. On Error GoTo ErrorHandler
  281. Set doc = ActiveDocument
  282. Dim s As Shape
  283. ps = Array(1)
  284. doc.Unit = cdrTenthMicron
  285. Set os = ActivePage.Shapes
  286. If os.Count > 0 Then
  287. doc.BeginCommandGroup "reduce nodes"
  288. For Each s In os
  289. s.ConvertToCurves
  290. If Not s.DisplayCurve Is Nothing Then
  291. s.Curve.AutoReduceNodes 50
  292. End If
  293. Next s
  294. doc.EndCommandGroup
  295. End If
  296. Application.Refresh
  297. ErrorHandler:
  298. MsgBox "s.Curve.AutoReduceNodes 只有高版本才支持本API"
  299. End Sub