I need your help in macros creation which will include two things:
1. PEN appears to be an active instrument in case of actuation
2. This instrument follows up my actions and in case I enter an 3 nodes some action activates. (and I need to get coordinates of nodes)
Sorry for my english
i'm not sure I understand what you wont...
1. Agreed (supposing that you are referring to 'Pen tool')...
2. Which instrument to follow your actions? A macro able to follow your mouse cursor keeping the 'Pen tool' and do something immediately after you created the third node, returning those three nodes coordinates?
I don't understands very well too, but run a macro not will break the pen tool workflow?
My suggestion is you implement the "ToolState" interface, creating a custom pen tool, if you need follow the mouse cursor. This solution is a more elegant.
Read this threads
If you run this macro after you had drawn a curve with the 'Pen Tool' and selected it, do you get what you want?
Sub Test()Dim CurSh As Shape, i As IntegerSet CurSh = ActiveShapeFor i = 1 To CurSh.Curve.Nodes.Count MsgBox Format(CurSh.Curve.Nodes(i).PositionX, "0.00") + " " + Format(CurSh.Curve.Nodes(i).PositionY, "0.00")Next iEnd Sub
You do not say anything...
If my supposition above is correct you can use the next event code:
Private nd As Long 'number of created nodes
Private Sub Document_ShapeDistort(ByVal Shape As Shape) Dim x1 As Double, x2 As Double, x3 As Double Dim y1 As Double, y2 As Double, y3 As Double On Error Resume Next 'in order to avoid error in case of shapes not being curves nd = Shape.Curve.Nodes.Count If Err.Number = 0 Then If nd Mod 3 = 0 Then x1 = Format(Shape.Curve.Nodes(nd - 2).PositionX, "00.00") x2 = Format(Shape.Curve.Nodes(nd - 1).PositionX, "00.00") x3 = Format(Shape.Curve.Nodes(nd).PositionX, "00.00") y1 = Format(Shape.Curve.Nodes(nd - 2).PositionY, "00.00") y2 = Format(Shape.Curve.Nodes(nd - 1).PositionY, "00.00") y3 = Format(Shape.Curve.Nodes(nd).PositionY, "00.00") Debug.Print nd, "event: " & x1 & ":" & y1 & " - " & x2 & ":" & y2 & " - " & x3 & ":" & y3 End If Else Err.Clear: On Error GoTo 0 End IfEnd Sub
It will return:
3 event: 15.97:257.51 - 87.23:207.42 - 138.73:258.93 6 event: 168.37:150.27 - 137.32:119.23 - 23.02:182.73 9 event: 22.32:213.77 - -36.24:234.94 - -46.12:148.86 12 event: 37.84:129.1 - 79.47:61.37 - 39.96:48.67
P.S. Is there a way to post nice html code in that new appearance of the forum?
Thank you very much. But I badly expressed. I post a picture about what I want to.