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
Thank you. Spasibo. I will read this issues in the future. Maybe I'll find my answer in them.
I know how to work with ready-made curve. ButI need to have drawn a maximum of 3 points, and there was a trigger.
Thank you. Spasibo bolshoe
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.