Guys
trying to learn to draw in VBA. I have got the drawing of lines understood but am having problems on how to do curves
I use the following code
Dim s As Shape Dim crv As Curve Dim sp As SubPath Dim c As New Color ActiveDocument.Unit = cdrMillimeter Set crv = CreateCurve(ActiveDocument) Set sp = crv.CreateSubPath(0, 0) sp.AppendLineSegment 0, 0, False ' NODE1 sp.AppendLineSegment 0, 100, False ' NODE2 sp.AppendLineSegment 200, 100, False ' NODE3 sp.AppendLineSegment 200, 75, False ' NODE4 sp.AppendLineSegment 0, 0, False ' NODE5 sp.Closed = True Set s = ActiveLayer.CreateCurve(crv)
This draws the shape below which I have annotated with the node numbers to match the code
I Want to curve the line between nodes 4 and 5 so that there is an even curve upwards as shown below
I am sure it it done by using SubPath.AppendCurveSegment method but i'm not sure how to implement it
is there any chance of an explanation of what figures are needed in order to achieve the above
My Understanding is the first two options are the x & y coordinates of the line you are curving but i'm not sure whether I use node 4 or 5
its after that I Don't know what they are. I Think options 4&6 are the angle of the curve but have no idea what to use
I wish Corel would come out with a complete reference guide with examples and explanations of each parameter as I find the API guide on the site very hit and miss which either give examples and no explanation or an explanation but no example
Any help is appreciated
Mark
IS it not done by defining the node type and the handle co-ordinates?
thanks Hywelharris
That's what I'm trying to find out I have no idea what figures to plug in and as said the documentation is very sketchy
SubPath.AppendCurveSegment is adding a Curve Segment to a Subpath. The shape of that segment depends on the lengths and angles of the starting and ending control points of that segment.
Look at the code we used recently for making a rectangular Curve with one side "puckered". In that case, we identified a Segment, changed it to be a Curve Segment, and then set lengths and angles for the starting and ending control points to shape it the way we wanted. With AppendCurveSegment, those can be set at the time that the segment is created.
Note that there is also a SubPath.AppendCurveSegment2 method that doesn't use the lengths and angles of the starting and ending control points of the segment, but instead specifies the x and y coordinates of those control points.
thanks Eskimo Segment2 seems to be the answer and I now understand how the coordinates work. Problem I now have is when I try to apply it as an envelope the text doesn't match
Using the following code
Dim s As Shape Dim crv As Curve Dim sp As SubPath Dim c As New Color Set s1 = ActiveLayer.CreateArtisticText(0, 0, "BCP", , , "Impact", 200) Set crv = CreateCurve(ActiveDocument) Set sp = crv.CreateSubPath(0, 0) sp.AppendLineSegment 0, 100, False sp.AppendCurveSegment2 200, 100, 100, 80, 200, 100, False sp.AppendLineSegment 200, 0, False sp.AppendCurveSegment2 0, 0, 100, 20, 0, 0, False sp.Closed = True Set s = ActiveLayer.CreateCurve(crv)
this draws the below shape and some text
I Then apply the text to the envelope using ActiveSelection.CreateEnvelopeFromCurve crv I get the following
as you can see the height of the text is not conforming to the envelope
If I manually apply the same envelope using the Envelope docker it apply's correctly as shown below
any ideas where i'm going wrong? I really appreciate your help
I don't know if you are already familiar with John's GDG Macros VBA Lessons, but there is a lot of good stuff there. As you mentioned using ActiveSelection, I would recommend looking at his GDG Macros Lesson 25: That Tricky Selection Shape, AKA: cdrSelectionShape.
In your code, s1 has already been set to the Artistic text you created. So, try using s1.CreateEnvelopeFromCurve crv.
Hi Eskimo
Thanks for the link Yes I knew about Johns Tutorials but hadn't watched them all
Yes makes sense now selecting the right type of shap makes all the difference rather than the generic Activeselection which I use far too much
s1 worked a charm Thanks for your help
I don't really know a lot about "selection shapes". I just remembered John's warning that it is easy to get into trouble with them!