![]() |
|
#1
|
|||
|
|||
|
Hi all,
I'm having a few problems trying to extract curves from a Corel DRAW text object in a C++ code. Code:
CorelDRAW::IDrawShapePtr shape;
…
// By now I know that shape is of cdrTextShape type
shape -> ConvertToCurves ();
CorelDRAW::IDrawCurvePtr curve = shape -> Curve;
CorelDRAW::IDrawSubPathsPtr subPaths = curve -> SubPaths;
long numSubPaths = subPaths -> Count;
for (long subPathIdx = 1; subPathIdx <= numSubPaths; subPathIdx ++)
{
CorelDRAW::IDrawNodesPtr nodes = subPath -> Nodes;
long numNodes = nodes -> Count;
for (long nodeIdx = 1; nodeIdx <= numNodes; nodeIdx ++)
{
CorelDRAW::IDrawNodePtr node = nodes -> Item [nodeIdx];
double startPosX = node -> Segment -> StartingControlPointX;
}
}
Actually the code above works just fine with one important exception: evidently Shape::ConvertToCurves() modifies the shape, so shape is no longer a text after calling this function! And I need it to stay the text… hence Problem 1: Problem 1. I’ve tried to produce a shape clone first, and then convert it to curves: Code:
CorelDRAW::IDrawShapePtr clone = shape -> Clone (0, 0); clone -> ConvertToCurves (); Nor Shape :: DisplayCurve works (instead of ConvertToCurves+Curve): it throws the E_NOINTERFACE exception. Problem 2. If the text is multi-colored (i.e. some letters have different color than others), then even the original code above (with no cloning) does not work: the line CorelDRAW::IDrawCurvePtr curve = shape -> Curve; throws the E_NOINTERFACE exception. TIA |
|
#2
|
||||
|
||||
|
Ok, let me answer your questions in sequence.
Yes, Shape::ConvertToCurves does change the type of the object. It does exactly what "Arrange > Convert To Curves (Ctrl+Q)" command does in the menu. When you do that, the object becomes the curve. If you want to create a temporary object, you might just duplicate it and then delete the copy when you are done: Code:
CorelDRAW::IDrawShapePtr sCopy = shape->Duplicate(0, 0); sCopy->ConvertToCurves(); sCopy->Curve->... sCopy.Delete The third problem of multicolored text. This is a side effect of convert to curves. When you convert a text object that has individual characters with different fills/outlines, it can no longer create a single curve that still retains those attributes (you can't have one path with one fill and another with some other fill). In order to work correctly, CorelDRAW's Convert To Curves command, creates several curves, each with its unique fill/outline attributes. And the result is grouped. So, when you convert a text object with various fills/outline, you'll end up with a group of curves. You can easily test for this by inspecting Shape::Type properties and ensuring it is cdrCurveShape and not cdrGroupShape. If it is a group, you can go through the individual shapes in the Shapes collection: Code:
if( sCopy->Type == CorelDRAW::cdrGroupShape)
{
for(int idx = 1; idx <= sCopy->Shapes->Count; idx++)
{
CorelDRAW::IDrawShapePtr sCurve = sCopy->Shapes->Item[idx];
// ... do your stuff with the current curve
}
}
|
|
#3
|
|||
|
|||
|
Thank you very much Alex.
Meanwhile I’ve achieved what I needed by first breaking apart text shapes, then doing my stuff and finally undoing the break aparts. But your solution is better (of course!) Incidentally, I was using Segment :: StartingControlPointX only for cdrCurveSegment-type segments and it was still crashing. Anyway, now it’s of no importance. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Striping a word down to the first letter only | knowbodynow | CorelDRAW/Corel DESIGNER VBA | 9 | 19-04-2007 15:14 |
| Adding text via VBA | knowbodynow | CorelDRAW/Corel DESIGNER VBA | 2 | 03-03-2006 09:15 |
| Text selection and sizing | ddonnahoe | CorelDRAW/Corel DESIGNER VBA | 5 | 17-05-2005 13:19 |
| format text dialog box implement | graphicdesigner | CorelDRAW/Corel DESIGNER VBA | 5 | 22-12-2004 13:37 |
| Reset text after text compression. | Bellekom | CorelDRAW/Corel DESIGNER VBA | 2 | 05-05-2004 06:14 |