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?
You do not say anything...
If my supposition above is correct you can use the next event code:
[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
[/code]
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.
But my code does exactly what you are asking...
Instead of MsgBox it return the values in ImmediateWindow (Ctrl + G) being in VBE (Alt + F11). If the macro will issue a MsgBox during you use the Pen tool you will be interrupted.
If that is not a problem, please use the next code:
This is an event! You do not have to start any Macro. It will just run when you work with Pen tool...
And this code must be placed in ThisDocument: Alt + F11 to open IDE. On the left side identify the VBA Project of the document where you wont to try it, click the cross on the left side (for instance VBAProject (Untitled-1)), click on the cross of CorelDraw Xx Objects and after that double click on ThisDocument. Paste here the next code and just work with Pen tool on that document. At each three nodes created a MsgBox containing the coordinates will pop up...
isn't that what you wont?
What variant of Corel do you use? Up to X6 you can save the document with that code (tested). On X8 the document saved events do not work. It is also a possibility to bypass that writing the code on the fly but firstly confirm that this is what you need...
Firstly, please, use it on a new document! Untitled...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
Option Explicit 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, "0.00") x2 = Format(Shape.Curve.Nodes(nd - 1).PositionX, "0.00") x3 = Format(Shape.Curve.Nodes(nd).PositionX, "0.00") y1 = Format(Shape.Curve.Nodes(nd - 2).PositionY, "0.00") y2 = Format(Shape.Curve.Nodes(nd - 1).PositionY, "0.00") y3 = Format(Shape.Curve.Nodes(nd).PositionY, "0.00") MsgBox x1 & ":" & y1 & vbCrLf & x2 & ":" & y2 & vbCrLf & x3 & ":" & y3 End If Else Err.Clear: On Error GoTo 0 End If End Sub
it's fantastic. the first time didn't work, and I do not understand what you need to do with it. But it's not quite the same.
I need something like: ActiveTool = cdrToolDrawBezier '(Bezier tool, I can't find the Pen Tool) and after drawing three points ie I need the action involving the coordinates of these points.
I confess I'm very confused...
1. I do not need such a code. I did it for you in order you to understand how to trigger the third node creation during its drawing... To be 'the same' with what? With your hidden thoughts...? Please specify what you need.
2. The code acts independent of the tool! It works similar for Besier, too. It works for all curves and Besier tool also creates curves... And Pen tool can be found in the same place like Besier tool. You just should pres the little arrow bottom right and choose it...
2 bis. What version of CorelDRAW do you use? I asked you before about that... At least in X6, X7 and X8 it is the same. I created the code in X8.
3. Do you need the code to draw that nodes or you manually will draw them and the code must do something at the third one?
When you need something please explain exactly what you need! Nobody likes Sisyphus work... As a general piece of advice: I took it like a challenge but if you need something else and you do not know how to explain what you need my spare of patience is not infinite... And it is not a matter of English, I'm afraid.
Thank you. I'm sorry that I caused you annoyance.It is very difficult to explain in a language that I do not know. Do you I already helped that code did, and now I know approximately where to "dig buried treasure". I will try to apply your advice for yourself. Thanks again and sorry.
No problem for me!
English is not my native language, too...
What I wonted to emphasize was: Please try to describe as well as possible what you need! And answer our questions as accurate as possible. Only in this way you increase your chances to receive a good answer...
What Corel version do you use? It is not 'the same' according to 'what'?
Will you manually draw the lines/nodes or macro code should do that?