Woodman.bas 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. VERSION 5.00
  2. Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} Woodman
  3. Caption = "批量标注尺寸节点"
  4. ClientHeight = 1980
  5. ClientLeft = 45
  6. ClientTop = 330
  7. ClientWidth = 3960
  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 sr.Add s
  70. Next s
  71. If sr.Count > 0 Then
  72. os.Shapes.FindShapes(Query:="@name ='DMKLine'").CreateSelection
  73. ActiveSelectionRange.Delete
  74. End If
  75. On Error GoTo 0
  76. Else
  77. make_sizes Shift
  78. End If
  79. doc.EndCommandGroup
  80. Application.Refresh
  81. End Sub
  82. Private Sub btn_sizes_up_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  83. make_sizes_sep "up", Shift
  84. End Sub
  85. Private Sub btn_sizes_dn_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  86. make_sizes_sep "dn", Shift
  87. End Sub
  88. Private Sub btn_sizes_lf_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  89. make_sizes_sep "lf", Shift
  90. End Sub
  91. Private Sub btn_sizes_ri_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  92. make_sizes_sep "ri", Shift
  93. End Sub
  94. Private Sub btn_sizes_btw_up_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  95. make_sizes_sep "upb", Shift
  96. End Sub
  97. Private Sub btn_sizes_btw_dn_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  98. make_sizes_sep "dnb", Shift
  99. End Sub
  100. Private Sub btn_sizes_btw_lf_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  101. make_sizes_sep "lfb", Shift
  102. End Sub
  103. Private Sub btn_sizes_btw_ri_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  104. make_sizes_sep "rib", Shift
  105. End Sub
  106. Sub make_sizes_sep(dr, Optional shft = 0)
  107. Set doc = ActiveDocument
  108. Dim s As Shape
  109. Dim pts As New SnapPoint, pte As New SnapPoint
  110. Dim os As ShapeRange
  111. un = doc.Unit
  112. doc.Unit = cdrMillimeter
  113. doc.BeginCommandGroup "make sizes"
  114. Set os = ActiveSelectionRange
  115. Dim border As Variant
  116. Dim Line_len As Double
  117. If shft > 1 Then
  118. Line_len = API.Set_Space_Width '// 设置文字空间间隙
  119. Else
  120. Line_len = API.Set_Space_Width(True) '// 只读文字空间间隙
  121. End If
  122. border = Array(cdrBottomRight, cdrBottomLeft, os.TopY + Line_len, os.TopY + 2 * Line_len, _
  123. cdrBottomRight, cdrTopRight, os.LeftX - Line_len, os.LeftX - 2 * Line_len)
  124. If chkOpposite.value Then border = Array(cdrTopRight, cdrTopLeft, os.BottomY - Line_len, os.BottomY - 2 * Line_len, _
  125. cdrBottomLeft, cdrTopLeft, os.RightX + Line_len, os.RightX + 2 * Line_len)
  126. If dr = "upbx" Or dr = "upb" Or dr = "dnb" Or dr = "up" Or dr = "dn" Then os.Sort "@shape1.left < @shape2.left"
  127. If dr = "lfbx" Or dr = "lfb" Or dr = "rib" Or dr = "lf" Or dr = "ri" Then os.Sort "@shape1.top > @shape2.top"
  128. If os.Count > 0 Then
  129. If os.Count > 1 And Len(dr) > 2 Then
  130. For i = 1 To os.Shapes.Count - 1
  131. Select Case dr
  132. Case "upbx":
  133. Set pts = os.Shapes(i).SnapPoints.BBox(border(0))
  134. Set pte = os.Shapes(i + 1).SnapPoints.BBox(border(1))
  135. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, 0, border(2), cdrDimensionStyleEngineering
  136. If shft > 0 And i = 1 Then
  137. Set pts = os.FirstShape.SnapPoints.BBox(border(0))
  138. Set pte = os.LastShape.SnapPoints.BBox(border(1))
  139. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, 0, border(3), cdrDimensionStyleEngineering
  140. End If
  141. Case "lfbx":
  142. Set pts = os.Shapes(i).SnapPoints.BBox(border(4))
  143. Set pte = os.Shapes(i + 1).SnapPoints.BBox(border(5))
  144. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, border(6), 0, cdrDimensionStyleEngineering
  145. If shft > 0 And i = 1 Then
  146. Set pts = os.FirstShape.SnapPoints.BBox(border(4))
  147. Set pte = os.LastShape.SnapPoints.BBox(border(5))
  148. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, border(7), 0, cdrDimensionStyleEngineering
  149. End If
  150. Case "upb":
  151. Set pts = os.Shapes(i).SnapPoints.BBox(cdrTopRight)
  152. Set pte = os.Shapes(i + 1).SnapPoints.BBox(cdrTopLeft)
  153. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, os.LeftX + os.SizeWidth / 10, os.TopY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  154. Case "dnb":
  155. Set pts = os.Shapes(i).SnapPoints.BBox(cdrBottomRight)
  156. Set pte = os.Shapes(i + 1).SnapPoints.BBox(cdrBottomLeft)
  157. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, os.LeftX + os.SizeWidth / 10, os.BottomY - os.SizeHeight / 10, cdrDimensionStyleEngineering
  158. Case "lfb":
  159. Set pts = os.Shapes(i).SnapPoints.BBox(cdrBottomLeft)
  160. Set pte = os.Shapes(i + 1).SnapPoints.BBox(cdrTopLeft)
  161. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, os.LeftX - os.SizeWidth / 10, os.BottomY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  162. Case "rib":
  163. Set pts = os.Shapes(i).SnapPoints.BBox(cdrBottomRight)
  164. Set pte = os.Shapes(i + 1).SnapPoints.BBox(cdrTopRight)
  165. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, os.RightX + os.SizeWidth / 10, os.BottomY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  166. End Select
  167. 'ActiveDocument.ClearSelection
  168. Next i
  169. Else
  170. If shft > 0 Then
  171. Select Case dr
  172. Case "up":
  173. Set pts = os.FirstShape.SnapPoints.BBox(cdrTopLeft)
  174. Set pte = os.LastShape.SnapPoints.BBox(cdrTopRight)
  175. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, os.LeftX + os.SizeWidth / 10, os.TopY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  176. Case "dn":
  177. Set pts = os.FirstShape.SnapPoints.BBox(cdrBottomLeft)
  178. Set pte = os.LastShape.SnapPoints.BBox(cdrBottomRight)
  179. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, os.LeftX + os.SizeWidth / 10, os.BottomY - os.SizeHeight / 10, cdrDimensionStyleEngineering
  180. Case "lf":
  181. Set pts = os.FirstShape.SnapPoints.BBox(cdrTopLeft)
  182. Set pte = os.LastShape.SnapPoints.BBox(cdrBottomLeft)
  183. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, os.LeftX - os.SizeWidth / 10, os.BottomY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  184. Case "ri":
  185. Set pts = os.FirstShape.SnapPoints.BBox(cdrTopRight)
  186. Set pte = os.LastShape.SnapPoints.BBox(cdrBottomRight)
  187. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, os.RightX + os.SizeWidth / 10, os.BottomY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  188. End Select
  189. Else
  190. For Each s In os.Shapes
  191. Select Case dr
  192. Case "up":
  193. Set pts = s.SnapPoints.BBox(cdrTopLeft)
  194. Set pte = s.SnapPoints.BBox(cdrTopRight)
  195. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, s.LeftX + s.SizeWidth / 10, s.TopY + s.SizeHeight / 10, cdrDimensionStyleEngineering
  196. Case "dn":
  197. Set pts = s.SnapPoints.BBox(cdrBottomLeft)
  198. Set pte = s.SnapPoints.BBox(cdrBottomRight)
  199. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, s.LeftX + s.SizeWidth / 10, s.BottomY - s.SizeHeight / 10, cdrDimensionStyleEngineering
  200. Case "lf":
  201. Set pts = s.SnapPoints.BBox(cdrTopLeft)
  202. Set pte = s.SnapPoints.BBox(cdrBottomLeft)
  203. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, s.LeftX - s.SizeWidth / 10, s.BottomY + s.SizeHeight / 10, cdrDimensionStyleEngineering
  204. Case "ri":
  205. Set pts = s.SnapPoints.BBox(cdrTopRight)
  206. Set pte = s.SnapPoints.BBox(cdrBottomRight)
  207. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, s.RightX + s.SizeWidth / 10, s.BottomY + s.SizeHeight / 10, cdrDimensionStyleEngineering
  208. End Select
  209. Next s
  210. End If
  211. End If
  212. End If
  213. os.CreateSelection
  214. doc.EndCommandGroup
  215. doc.Unit = un
  216. End Sub
  217. Sub make_sizes(Optional shft = 0)
  218. Set doc = ActiveDocument
  219. Dim s As Shape
  220. Dim pts As SnapPoint, pte As SnapPoint
  221. Dim os As ShapeRange
  222. un = doc.Unit
  223. doc.Unit = cdrMillimeter
  224. doc.BeginCommandGroup "make sizes"
  225. Set os = ActiveSelectionRange
  226. If os.Count > 0 Then
  227. For Each s In os.Shapes
  228. Set pts = s.SnapPoints.BBox(cdrTopLeft)
  229. Set pte = s.SnapPoints.BBox(cdrTopRight)
  230. Set ptle = s.SnapPoints.BBox(cdrBottomLeft)
  231. If shft <> 6 Then ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, ptle, True, s.LeftX - s.SizeWidth / 10, s.BottomY + s.SizeHeight / 10, cdrDimensionStyleEngineering
  232. If shft <> 3 Then ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, s.LeftX + s.SizeWidth / 10, s.TopY + s.SizeHeight / 10, cdrDimensionStyleEngineering
  233. Next s
  234. End If
  235. doc.EndCommandGroup
  236. doc.Unit = un
  237. End Sub
  238. Public Function make_selection(Optional mode = "fcolor", Optional sel = True, Optional OSS As ShapeRange = Nothing, Optional colr = Nothing) As ShapeRange
  239. Dim s As Shape, lst As Shape
  240. Dim sr As ShapeRange
  241. 'Dim os As ShapeRange
  242. Set doc = ActiveDocument
  243. doc.Unit = cdrTenthMicron
  244. If OSS Is Nothing Then
  245. If toolspanel.num_list.value Or mode = "locked" Then
  246. Set os = ActivePage
  247. Else
  248. Set os = ActiveSelectionRange
  249. End If
  250. Else
  251. Set os = OSS
  252. End If
  253. Set sr = ActiveSelectionRange
  254. sr.RemoveAll
  255. If sel Then ActiveDocument.ClearSelection
  256. Set lst = os.Shapes.First
  257. For Each s In os.Shapes
  258. Select Case mode
  259. Case "ocolor": If s.Outline.Type <> cdrNoOutline And s.Shapes.Count = 0 And s.Outline.Color.HexValue = colr.HexValue Then sr.Add s
  260. Case "fcolor": If s.Fill.Type <> cdrNoFill And s.Shapes.Count = 0 And s.Fill.UniformColor.HexValue = colr.HexValue Then sr.Add s
  261. Case "nofil": If s.Fill.Type = cdrNoFill And s.Shapes.Count = 0 Then sr.Add s
  262. Case "fil": If s.Fill.Type <> cdrNoFill And s.Shapes.Count = 0 Then sr.Add s
  263. Case "abr": If s.Outline.Type <> cdrNoOutline And s.Shapes.Count = 0 Then sr.Add s
  264. Case "noabr": If s.Outline.Type = cdrNoOutline And s.Shapes.Count = 0 Then sr.Add s
  265. Case "open": If Not s.DisplayCurve Is Nothing Then If Not s.DisplayCurve.Closed Then sr.Add s
  266. Case "closed": If Not s.DisplayCurve Is Nothing Then If s.DisplayCurve.Closed Then sr.Add s
  267. Case "single": If s.Shapes.Count = 0 Then sr.Add s
  268. Case "dashed": If s.Outline.Style.DashCount > 0 Then sr.Add s
  269. Case "groups": If s.Shapes.Count > 0 And s.Effect Is Nothing Then sr.Add s
  270. Case "text": If s.Shapes.Count = 0 And s.Type = cdrTextShape Then sr.Add s
  271. Case "notext": If s.Shapes.Count = 0 And s.Type <> cdrTextShape Then sr.Add s
  272. Case "images": If s.Type = cdrBitmapShape Then sr.Add s
  273. Case "locked": If s.Locked Then sr.Add s
  274. Case "effects": If s.Effects.Count > 0 Or Not s.Effect Is Nothing Then sr.Add s
  275. Case "noeffects": If s.Effects.Count = 0 And s.Effect Is Nothing Then sr.Add s
  276. Case "bigger":
  277. arelst = lst.SizeHeight * lst.SizeWidth
  278. ares = s.SizeHeight * s.SizeWidth
  279. If ares >= arelst Then
  280. are = one_shape_area(lst)
  281. If one_shape_area(s) >= are Then sr.Add s
  282. End If
  283. Case "smaller":
  284. arelst = lst.SizeHeight * lst.SizeWidth
  285. ares = s.SizeHeight * s.SizeWidth
  286. If ares <= arelst Then
  287. are = one_shape_area(lst)
  288. If one_shape_area(s) <= are Then sr.Add s
  289. End If
  290. Case "last":
  291. If lst.Fill.Type = cdrNoFill Then
  292. 's.CreateSelection
  293. If s.Outline.Type <> cdrNoOutline Then If s.Outline.Color.HexValue = lst.Outline.Color.HexValue Then sr.Add s
  294. Else
  295. If s.Fill.UniformColor.HexValue = lst.Fill.UniformColor.HexValue Then sr.Add s
  296. End If
  297. End Select
  298. Next s
  299. If sr.Shapes.Count > 0 And sel Then sr.CreateSelection
  300. Set make_selection = sr
  301. Application.Refresh
  302. ActiveWindow.Activate
  303. End Function
  304. Public Function get_events(btn As String, Optional shft = 0, Optional click = 1)
  305. out = "ok"
  306. get_events = out
  307. End Function
  308. Private Sub btn_join_nodes_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  309. ActiveSelection.CustomCommand "ConvertTo", "JoinCurves"
  310. Application.Refresh
  311. End Sub
  312. Private Sub btn_nodes_reduce_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  313. On Error GoTo ErrorHandler
  314. Set doc = ActiveDocument
  315. Dim s As Shape
  316. ps = Array(1)
  317. doc.Unit = cdrTenthMicron
  318. Set os = ActivePage.Shapes
  319. If os.Count > 0 Then
  320. doc.BeginCommandGroup "reduce nodes"
  321. For Each s In os
  322. s.ConvertToCurves
  323. If Not s.DisplayCurve Is Nothing Then
  324. s.Curve.AutoReduceNodes 50
  325. End If
  326. Next s
  327. doc.EndCommandGroup
  328. End If
  329. Application.Refresh
  330. ErrorHandler:
  331. MsgBox "s.Curve.AutoReduceNodes 只有高版本才支持本API"
  332. End Sub
  333. '// 使用标记线批量建立尺寸标注
  334. Private Sub MarkLines_Makesize_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  335. Dim sr As ShapeRange
  336. Set sr = ActiveSelectionRange
  337. If Button = 2 Then
  338. CutLines.Dimension_MarkLines cdrAlignLeft, chkOpposite.value
  339. make_sizes_sep "lfbx", Shift
  340. Else
  341. CutLines.Dimension_MarkLines cdrAlignTop, chkOpposite.value
  342. Label_Makesizes.Caption = "试试右键"
  343. make_sizes_sep "upbx", Shift
  344. End If
  345. sr.CreateSelection
  346. End Sub
  347. Private Sub chkOpposite_Click()
  348. ' Debug.Print chkOpposite.value
  349. End Sub
  350. '// 使用手工选节点建立尺寸标注,使用Ctrl分离尺寸标注
  351. Private Sub Manual_Makesize_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  352. If Button = 2 Then
  353. '// 右键
  354. ElseIf Shift = fmCtrlMask Then
  355. Slanted_Makesize '// 手动标注倾斜尺寸
  356. Else
  357. Untie_MarkLines '// 解绑尺寸,分离尺寸
  358. End If
  359. End Sub
  360. '// 解绑尺寸,分离尺寸
  361. Private Function Untie_MarkLines()
  362. Dim os As ShapeRange, dss As New ShapeRange
  363. Set os = ActiveSelectionRange
  364. For Each s In os.Shapes
  365. If s.Type = cdrLinearDimensionShape Then
  366. dss.Add s
  367. End If
  368. Next s
  369. If dss.Count > 0 Then
  370. dss.BreakApartEx
  371. os.Shapes.FindShapes(Query:="@name ='DMKLine'").CreateSelection
  372. ActiveSelectionRange.Delete
  373. End If
  374. End Function
  375. '// 手动标注倾斜尺寸
  376. Private Function Slanted_Makesize()
  377. On Error GoTo ErrorHandler
  378. API.BeginOpt
  379. Dim nr As NodeRange, cnt As Integer
  380. Dim sr As ShapeRange
  381. Dim x1 As Double, y1 As Double
  382. Dim x2 As Double, y2 As Double
  383. Set sr = ActiveSelectionRange
  384. Set nr = ActiveShape.Curve.Selection
  385. If chkOpposite.value = False Then
  386. Slanted_Sort_Make sr '// 排序标注倾斜尺寸
  387. Exit Function
  388. End If
  389. If nr.Count < 2 Then Exit Function
  390. cnt = nr.Count
  391. While cnt > 1
  392. x1 = nr(cnt).PositionX
  393. y1 = nr(cnt).PositionY
  394. x2 = nr(cnt - 1).PositionX
  395. y2 = nr(cnt - 1).PositionY
  396. Set pts = CreateSnapPoint(x1, y1)
  397. Set pte = CreateSnapPoint(x2, y2)
  398. ActiveLayer.CreateLinearDimension cdrDimensionSlanted, pts, pte, True, x1 - 20, y1 + 20, cdrDimensionStyleEngineering
  399. cnt = cnt - 1
  400. Wend
  401. ErrorHandler:
  402. API.EndOpt
  403. End Function
  404. '// 排序标注倾斜尺寸
  405. Private Function Slanted_Sort_Make(shs As ShapeRange)
  406. Dim sr As New ShapeRange, sr_copy As New ShapeRange
  407. Dim s As Shape, sh As Shape
  408. Dim nr As NodeRange
  409. For Each sh In shs
  410. Set nr = sh.Curve.Selection
  411. For Each n In nr
  412. Set s = ActiveLayer.CreateEllipse2(n.PositionX, n.PositionY, 0.5, 0.5)
  413. sr.Add s
  414. Next n
  415. Next sh
  416. CutLines.RemoveDuplicates sr '// 简单删除重复算法
  417. sr.Sort "@shape1.left < @shape2.left"
  418. sr.CreateSelection
  419. Set sr_copy = ActiveSelectionRange
  420. ' Debug.Print sr_copy.Count
  421. For i = 1 To sr_copy.Count - 1
  422. x1 = sr_copy(i + 1).CenterX
  423. y1 = sr_copy(i + 1).CenterY
  424. x2 = sr_copy(i).CenterX
  425. y2 = sr_copy(i).CenterY
  426. Set pts = CreateSnapPoint(x1, y1)
  427. Set pte = CreateSnapPoint(x2, y2)
  428. ActiveLayer.CreateLinearDimension cdrDimensionSlanted, pts, pte, True, x1 - 20, y1 + 20, cdrDimensionStyleEngineering
  429. Next i
  430. sr_copy.Delete
  431. API.EndOpt
  432. End Function