2024_01_08_ctrlPressed_FindEdgeNode.bas 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. Private Declare PtrSafe Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
  2. Sub 工具栏图标Ctrl扩展功能()
  3. Dim ctrlPressed As Boolean
  4. ' 获取Ctrl键的状态
  5. ctrlPressed = GetAsyncKeyState(17) And &H8000
  6. ' 检查Ctrl键是否按下
  7. If ctrlPressed Then
  8. MsgBox "Ctrl键被按下了。 我要运行强大的扩展功能了"
  9. autogroup("group", 1).CreateSelection
  10. Else
  11. Tools.guideangle ActiveSelectionRange, 0# ' 右键 0距离贴紧
  12. MsgBox "Ctrl键未被按下。我躺平了。"
  13. End If
  14. End Sub
  15. '// 日醺Apollo 2024-01-18 快速查极点测试成功,代码如下,供参考。
  16. Sub FindEdgeNode()
  17. Dim s As Shape, nd As Node
  18. Dim ndIndex As Integer
  19. ActiveDocument.Unit = cdrMillimeter
  20. Dim x As Double, y As Double, w As Double, h As Double
  21. Set s = ActiveShape
  22. s.GetBoundingBox x, y, w, h
  23. s.SetBoundingBox x, y, 1, h
  24. Set nd = s.Curve.FindNodeAtPoint(x, y + h)
  25. If Not nd Is Nothing Then
  26. ndIndex = nd.Index
  27. MsgBox "当前顶点的序号为" & ndIndex & " 其座标x为" & nd.PositionX & " y为" & nd.PositionY, vbCritical
  28. End If
  29. End Sub