Woodman.bas 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. VERSION 5.00
  2. Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} Woodman
  3. Caption = "Batch Dimension Nodes"
  4. ClientHeight = 1995
  5. ClientLeft = 45
  6. ClientTop = 330
  7. ClientWidth = 3930
  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. '// This is free and unencumbered software released into the public domain.
  17. '// For more information, please refer to https://github.com/hongwenjun
  18. #If VBA7 Then
  19. Private Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
  20. Private Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
  21. Private Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  22. Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  23. Private Declare PtrSafe Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
  24. #Else
  25. Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
  26. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
  27. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  28. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  29. Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
  30. #End If
  31. Private Const GWL_STYLE As Long = (-16)
  32. Private Const GWL_EXSTYLE = (-20)
  33. Private Const WS_CAPTION As Long = &HC00000
  34. Private Const WS_EX_DLGMODALFRAME = &H1&
  35. Private Sub chkOpposite_Click()
  36. MiniForm
  37. End Sub
  38. '// Minimizes the window and retains dimensioning functionality '// 最小化窗口并保留标注尺寸功能
  39. Private Function MiniForm()
  40. Dim IStyle As Long
  41. Dim hWnd As Long
  42. hWnd = FindWindow("ThunderDFrame", Woodman.Caption)
  43. IStyle = GetWindowLong(hWnd, GWL_STYLE)
  44. IStyle = IStyle And Not WS_CAPTION
  45. SetWindowLong hWnd, GWL_STYLE, IStyle
  46. DrawMenuBar hWnd
  47. IStyle = GetWindowLong(hWnd, GWL_EXSTYLE) And Not WS_EX_DLGMODALFRAME
  48. SetWindowLong hWnd, GWL_EXSTYLE, IStyle
  49. Dim ctl As Control
  50. For Each ctl In Woodman.Controls
  51. ctl.Visible = False
  52. ctl.Top = 2
  53. Next ctl
  54. With Woodman
  55. .StartUpPosition = 0
  56. .Left = Val(GetSetting("LYVBA", "Settings", "Left", "400")) + 318
  57. .Top = Val(GetSetting("LYVBA", "Settings", "Top", "55")) - 2
  58. .Height = 30
  59. .Width = 100
  60. .MarkLines_Makesize.Visible = True
  61. .btn_Makesizes.Visible = True
  62. .Manual_Makesize.Visible = True
  63. .chkOpposite.Visible = True
  64. .X_EXIT.Visible = True
  65. .MarkLines_Makesize.Left = 0
  66. .btn_Makesizes.Left = 25
  67. .Manual_Makesize.Left = 50
  68. .chkOpposite.Left = 75: .chkOpposite.Top = 14
  69. .X_EXIT.Left = 85: .X_EXIT.Top = 0
  70. End With
  71. End Function
  72. Private Sub btn_square_hi_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  73. ActiveDocument.BeginCommandGroup: Application.Optimization = True
  74. Set os = ActiveSelectionRange
  75. Set ss = os.Shapes
  76. uc = 0
  77. For Each s In ss
  78. s.SizeWidth = s.SizeHeight
  79. uc = uc + 1
  80. Next s
  81. Application.Optimization = False
  82. ActiveWindow.Refresh: Application.Refresh
  83. End Sub
  84. Private Sub btn_square_wi_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  85. ActiveDocument.BeginCommandGroup: Application.Optimization = True
  86. Set os = ActiveSelectionRange
  87. Set ss = os.Shapes
  88. uc = 0
  89. For Each s In ss
  90. s.SizeHeight = s.SizeWidth
  91. uc = uc + 1
  92. Next s
  93. Application.Optimization = False
  94. ActiveWindow.Refresh: Application.Refresh
  95. End Sub
  96. Private Sub btn_Makesizes_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  97. Dim os As ShapeRange
  98. Dim s As Shape
  99. Dim sr As ShapeRange
  100. Set doc = ActiveDocument
  101. 'rasm.Dimension.TextShape.Text.Story.size = CLng(fnt)
  102. 'rasm.Style.GetProperty("dimension").SetProperty "precision", 0
  103. 'rasm.Style.GetProperty("dimension").SetProperty "units", 3
  104. doc.BeginCommandGroup "delete sizes"
  105. Set sr = ActiveSelectionRange
  106. sr.RemoveAll
  107. If Shift = 4 Then
  108. On Error Resume Next
  109. Set os = ActiveSelectionRange
  110. For Each s In os.Shapes
  111. If s.Type = cdrLinearDimensionShape Then s.Delete
  112. Next s
  113. On Error GoTo 0
  114. ElseIf Shift = 1 Then
  115. Set os = ActiveSelectionRange
  116. For Each s In os.Shapes
  117. If s.Type = cdrLinearDimensionShape Then sr.Add s
  118. Next s
  119. sr.CreateSelection
  120. On Error GoTo 0
  121. ElseIf Shift = 2 Then
  122. On Error Resume Next
  123. Set os = ActiveSelectionRange
  124. For Each s In os.Shapes
  125. If s.Type = cdrLinearDimensionShape Then s.Delete
  126. Next s
  127. If os.Count > 0 Then
  128. os.Shapes.FindShapes(Query:="@name ='DMKLine'").CreateSelection
  129. ActiveSelectionRange.Delete
  130. End If
  131. On Error GoTo 0
  132. Else
  133. make_sizes Shift
  134. End If
  135. doc.EndCommandGroup
  136. Application.Refresh
  137. End Sub
  138. Private Sub btn_sizes_up_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  139. make_sizes_sep "up", Shift
  140. End Sub
  141. Private Sub btn_sizes_dn_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  142. make_sizes_sep "dn", Shift
  143. End Sub
  144. Private Sub btn_sizes_lf_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  145. make_sizes_sep "lf", Shift
  146. End Sub
  147. Private Sub btn_sizes_ri_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  148. make_sizes_sep "ri", Shift
  149. End Sub
  150. Private Sub btn_sizes_btw_up_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  151. make_sizes_sep "upb", Shift
  152. End Sub
  153. Private Sub btn_sizes_btw_dn_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  154. make_sizes_sep "dnb", Shift
  155. End Sub
  156. Private Sub btn_sizes_btw_lf_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  157. make_sizes_sep "lfb", Shift
  158. End Sub
  159. Private Sub btn_sizes_btw_ri_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  160. make_sizes_sep "rib", Shift
  161. End Sub
  162. Sub make_sizes_sep(dr, Optional shft = 0, Optional ByVal mirror As Boolean = False)
  163. Set doc = ActiveDocument
  164. Dim s As Shape
  165. Dim pts As New SnapPoint, pte As New SnapPoint
  166. Dim os As ShapeRange
  167. un = doc.Unit
  168. doc.Unit = cdrMillimeter
  169. doc.BeginCommandGroup "make sizes"
  170. Set os = ActiveSelectionRange
  171. Dim border As Variant
  172. Dim Line_len As Double
  173. If shft > 1 Then
  174. Line_len = API.Set_Space_Width '// 设置文字空间间隙
  175. Else
  176. Line_len = API.Set_Space_Width(True) '// 只读文字空间间隙
  177. End If
  178. border = Array(cdrBottomRight, cdrBottomLeft, os.TopY + Line_len, os.TopY + 2 * Line_len, _
  179. cdrBottomRight, cdrTopRight, os.LeftX - Line_len, os.LeftX - 2 * Line_len)
  180. If mirror = True Then border = Array(cdrTopRight, cdrTopLeft, os.BottomY - Line_len, os.BottomY - 2 * Line_len, _
  181. cdrBottomLeft, cdrTopLeft, os.RightX + Line_len, os.RightX + 2 * Line_len)
  182. If dr = "upbx" Or dr = "upb" Or dr = "dnb" Or dr = "up" Or dr = "dn" Then os.Sort "@shape1.left < @shape2.left"
  183. If dr = "lfbx" Or dr = "lfb" Or dr = "rib" Or dr = "lf" Or dr = "ri" Then os.Sort "@shape1.top > @shape2.top"
  184. If os.Count > 0 Then
  185. If os.Count > 1 And Len(dr) > 2 Then
  186. For i = 1 To os.Shapes.Count - 1
  187. Select Case dr
  188. Case "upbx":
  189. Set pts = os.Shapes(i).SnapPoints.BBox(border(0))
  190. Set pte = os.Shapes(i + 1).SnapPoints.BBox(border(1))
  191. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, 0, border(2), cdrDimensionStyleEngineering
  192. If shft > 0 And i = 1 Then
  193. Set pts = os.FirstShape.SnapPoints.BBox(border(0))
  194. Set pte = os.LastShape.SnapPoints.BBox(border(1))
  195. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, 0, border(3), cdrDimensionStyleEngineering
  196. End If
  197. Case "lfbx":
  198. Set pts = os.Shapes(i).SnapPoints.BBox(border(4))
  199. Set pte = os.Shapes(i + 1).SnapPoints.BBox(border(5))
  200. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, border(6), 0, cdrDimensionStyleEngineering
  201. If shft > 0 And i = 1 Then
  202. Set pts = os.FirstShape.SnapPoints.BBox(border(4))
  203. Set pte = os.LastShape.SnapPoints.BBox(border(5))
  204. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, border(7), 0, cdrDimensionStyleEngineering
  205. End If
  206. Case "upb":
  207. Set pts = os.Shapes(i).SnapPoints.BBox(cdrTopRight)
  208. Set pte = os.Shapes(i + 1).SnapPoints.BBox(cdrTopLeft)
  209. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, os.LeftX + os.SizeWidth / 10, os.TopY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  210. Case "dnb":
  211. Set pts = os.Shapes(i).SnapPoints.BBox(cdrBottomRight)
  212. Set pte = os.Shapes(i + 1).SnapPoints.BBox(cdrBottomLeft)
  213. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, os.LeftX + os.SizeWidth / 10, os.BottomY - os.SizeHeight / 10, cdrDimensionStyleEngineering
  214. Case "lfb":
  215. Set pts = os.Shapes(i).SnapPoints.BBox(cdrBottomLeft)
  216. Set pte = os.Shapes(i + 1).SnapPoints.BBox(cdrTopLeft)
  217. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, os.LeftX - os.SizeWidth / 10, os.BottomY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  218. Case "rib":
  219. Set pts = os.Shapes(i).SnapPoints.BBox(cdrBottomRight)
  220. Set pte = os.Shapes(i + 1).SnapPoints.BBox(cdrTopRight)
  221. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, os.RightX + os.SizeWidth / 10, os.BottomY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  222. End Select
  223. 'ActiveDocument.ClearSelection
  224. Next i
  225. Else
  226. If shft > 0 Then
  227. Select Case dr
  228. Case "up":
  229. Set pts = os.FirstShape.SnapPoints.BBox(cdrTopLeft)
  230. Set pte = os.LastShape.SnapPoints.BBox(cdrTopRight)
  231. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, os.LeftX + os.SizeWidth / 10, os.TopY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  232. Case "dn":
  233. Set pts = os.FirstShape.SnapPoints.BBox(cdrBottomLeft)
  234. Set pte = os.LastShape.SnapPoints.BBox(cdrBottomRight)
  235. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, os.LeftX + os.SizeWidth / 10, os.BottomY - os.SizeHeight / 10, cdrDimensionStyleEngineering
  236. Case "lf":
  237. Set pts = os.FirstShape.SnapPoints.BBox(cdrTopLeft)
  238. Set pte = os.LastShape.SnapPoints.BBox(cdrBottomLeft)
  239. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, os.LeftX - os.SizeWidth / 10, os.BottomY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  240. Case "ri":
  241. Set pts = os.FirstShape.SnapPoints.BBox(cdrTopRight)
  242. Set pte = os.LastShape.SnapPoints.BBox(cdrBottomRight)
  243. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, os.RightX + os.SizeWidth / 10, os.BottomY + os.SizeHeight / 10, cdrDimensionStyleEngineering
  244. End Select
  245. Else
  246. For Each s In os.Shapes
  247. Select Case dr
  248. Case "up":
  249. Set pts = s.SnapPoints.BBox(cdrTopLeft)
  250. Set pte = s.SnapPoints.BBox(cdrTopRight)
  251. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, s.LeftX + s.SizeWidth / 10, s.TopY + s.SizeHeight / 10, cdrDimensionStyleEngineering
  252. Case "dn":
  253. Set pts = s.SnapPoints.BBox(cdrBottomLeft)
  254. Set pte = s.SnapPoints.BBox(cdrBottomRight)
  255. ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, s.LeftX + s.SizeWidth / 10, s.BottomY - s.SizeHeight / 10, cdrDimensionStyleEngineering
  256. Case "lf":
  257. Set pts = s.SnapPoints.BBox(cdrTopLeft)
  258. Set pte = s.SnapPoints.BBox(cdrBottomLeft)
  259. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, s.LeftX - s.SizeWidth / 10, s.BottomY + s.SizeHeight / 10, cdrDimensionStyleEngineering
  260. Case "ri":
  261. Set pts = s.SnapPoints.BBox(cdrTopRight)
  262. Set pte = s.SnapPoints.BBox(cdrBottomRight)
  263. ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, pte, True, s.RightX + s.SizeWidth / 10, s.BottomY + s.SizeHeight / 10, cdrDimensionStyleEngineering
  264. End Select
  265. Next s
  266. End If
  267. End If
  268. End If
  269. os.CreateSelection
  270. doc.EndCommandGroup
  271. doc.Unit = un
  272. End Sub
  273. Sub make_sizes(Optional shft = 0)
  274. Set doc = ActiveDocument
  275. Dim s As Shape
  276. Dim pts As SnapPoint, pte As SnapPoint
  277. Dim os As ShapeRange
  278. un = doc.Unit
  279. doc.Unit = cdrMillimeter
  280. doc.BeginCommandGroup "make sizes"
  281. Set os = ActiveSelectionRange
  282. If os.Count > 0 Then
  283. For Each s In os.Shapes
  284. Set pts = s.SnapPoints.BBox(cdrTopLeft)
  285. Set pte = s.SnapPoints.BBox(cdrTopRight)
  286. Set ptle = s.SnapPoints.BBox(cdrBottomLeft)
  287. If shft <> 6 Then ActiveLayer.CreateLinearDimension cdrDimensionVertical, pts, ptle, True, s.LeftX - s.SizeWidth / 10, s.BottomY + s.SizeHeight / 10, cdrDimensionStyleEngineering
  288. If shft <> 3 Then ActiveLayer.CreateLinearDimension cdrDimensionHorizontal, pts, pte, True, s.LeftX + s.SizeWidth / 10, s.TopY + s.SizeHeight / 10, cdrDimensionStyleEngineering
  289. Next s
  290. End If
  291. doc.EndCommandGroup
  292. doc.Unit = un
  293. End Sub
  294. Private Sub btn_join_nodes_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  295. ActiveSelection.CustomCommand "ConvertTo", "JoinCurves"
  296. Application.Refresh
  297. End Sub
  298. Private Sub btn_nodes_reduce_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  299. On Error GoTo ErrorHandler
  300. Set doc = ActiveDocument
  301. Dim s As Shape
  302. ps = Array(1)
  303. doc.Unit = cdrTenthMicron
  304. Set os = ActivePage.Shapes
  305. If os.Count > 0 Then
  306. doc.BeginCommandGroup "reduce nodes"
  307. For Each s In os
  308. s.ConvertToCurves
  309. If Not s.DisplayCurve Is Nothing Then
  310. s.Curve.AutoReduceNodes 50
  311. End If
  312. Next s
  313. doc.EndCommandGroup
  314. End If
  315. Application.Refresh
  316. ErrorHandler:
  317. MsgBox "s.Curve.AutoReduceNodes 只有高版本才支持本API"
  318. End Sub
  319. '// 使用标记线批量建立尺寸标注: 左键上标注,右键右标注
  320. Private Sub MarkLines_Makesize_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  321. Dim sr As ShapeRange
  322. Set sr = ActiveSelectionRange
  323. '// 右键
  324. If Button = 2 Then
  325. If chkOpposite.value = True Then
  326. CutLines.Dimension_MarkLines cdrAlignTop, True
  327. make_sizes_sep "upbx", Shift, True
  328. Else
  329. CutLines.Dimension_MarkLines cdrAlignLeft, True
  330. make_sizes_sep "lfbx", Shift, True
  331. End If
  332. '// 左键
  333. ElseIf Button = 1 Then
  334. If chkOpposite.value = True Then
  335. CutLines.Dimension_MarkLines cdrAlignLeft, False
  336. make_sizes_sep "lfbx", Shift, False
  337. Else
  338. CutLines.Dimension_MarkLines cdrAlignTop, False
  339. make_sizes_sep "upbx", Shift, False
  340. End If
  341. End If
  342. sr.CreateSelection
  343. End Sub
  344. '// 使用手工选节点建立尺寸标注,使用Ctrl分离尺寸标注
  345. Private Sub Manual_Makesize_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  346. If Button = 2 Then
  347. '// 右键
  348. ElseIf Shift = fmCtrlMask Then
  349. Slanted_Makesize '// 手动标注倾斜尺寸
  350. Else
  351. Untie_MarkLines '// 解绑尺寸,分离尺寸
  352. End If
  353. End Sub
  354. '// 解绑尺寸,分离尺寸
  355. Private Function Untie_MarkLines()
  356. Dim os As ShapeRange, dss As New ShapeRange
  357. Set os = ActiveSelectionRange
  358. For Each s In os.Shapes
  359. If s.Type = cdrLinearDimensionShape Then
  360. dss.Add s
  361. End If
  362. Next s
  363. If dss.Count > 0 Then
  364. dss.BreakApartEx
  365. os.Shapes.FindShapes(Query:="@name ='DMKLine'").CreateSelection
  366. ActiveSelectionRange.Delete
  367. End If
  368. End Function
  369. '// 手动标注倾斜尺寸
  370. Private Function Slanted_Makesize()
  371. On Error GoTo ErrorHandler
  372. API.BeginOpt
  373. Dim nr As NodeRange, cnt As Integer
  374. Dim sr As ShapeRange
  375. Dim x1 As Double, y1 As Double
  376. Dim x2 As Double, y2 As Double
  377. Set sr = ActiveSelectionRange
  378. Set nr = ActiveShape.Curve.Selection
  379. If chkOpposite.value = False Then
  380. Slanted_Sort_Make sr '// 排序标注倾斜尺寸
  381. Exit Function
  382. End If
  383. If nr.Count < 2 Then Exit Function
  384. cnt = nr.Count
  385. While cnt > 1
  386. x1 = nr(cnt).PositionX
  387. y1 = nr(cnt).PositionY
  388. x2 = nr(cnt - 1).PositionX
  389. y2 = nr(cnt - 1).PositionY
  390. Set pts = CreateSnapPoint(x1, y1)
  391. Set pte = CreateSnapPoint(x2, y2)
  392. ActiveLayer.CreateLinearDimension cdrDimensionSlanted, pts, pte, True, x1 - 20, y1 + 20, cdrDimensionStyleEngineering
  393. cnt = cnt - 1
  394. Wend
  395. ErrorHandler:
  396. API.EndOpt
  397. End Function
  398. '// 排序标注倾斜尺寸
  399. Private Function Slanted_Sort_Make(shs As ShapeRange)
  400. Dim sr As New ShapeRange, sr_copy As New ShapeRange
  401. Dim s As Shape, sh As Shape
  402. Dim nr As NodeRange
  403. For Each sh In shs
  404. Set nr = sh.Curve.Selection
  405. For Each n In nr
  406. Set s = ActiveLayer.CreateEllipse2(n.PositionX, n.PositionY, 0.5, 0.5)
  407. sr.Add s
  408. Next n
  409. Next sh
  410. CutLines.RemoveDuplicates sr '// 简单删除重复算法
  411. sr.Sort "@shape1.left < @shape2.left"
  412. sr.CreateSelection
  413. Set sr_copy = ActiveSelectionRange
  414. ' Debug.Print sr_copy.Count
  415. For i = 1 To sr_copy.Count - 1
  416. x1 = sr_copy(i + 1).CenterX
  417. y1 = sr_copy(i + 1).CenterY
  418. x2 = sr_copy(i).CenterX
  419. y2 = sr_copy(i).CenterY
  420. Set pts = CreateSnapPoint(x1, y1)
  421. Set pte = CreateSnapPoint(x2, y2)
  422. ActiveLayer.CreateLinearDimension cdrDimensionSlanted, pts, pte, True, x1 - 20, y1 + 20, cdrDimensionStyleEngineering
  423. Next i
  424. sr_copy.Delete
  425. API.EndOpt
  426. End Function
  427. Private Sub X_EXIT_Click()
  428. Unload Me '// EXIT
  429. End Sub