OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-01-2009, 15:36
dlpfis
Guest
 
Posts: n/a
Default fit text to curve in a windows app

I am creating an app which requires me to fit some text to a circle. I can create the line of text progmatically, and i can create the sphere, but I cant find the class for the fit to path feature in corel.

I am writing this in C# but a VB solution would be just as welcome. Thanks.
Reply With Quote
  #2  
Old 09-01-2009, 16:00
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,782
Blog Entries: 11
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Here you go

This is in VBA, hope it helps.
Code:
Sub TestFitToPath()
    Dim sText As Shape, sEllipse As Shape
    
    Set sText = ActiveLayer.CreateArtisticText(0, 0, "Text On Path")
    Set sEllipse = ActiveLayer.CreateEllipse2(4, 5, 2)
    
    sText.Text.FitToPath sEllipse
    sText.Effects(1).TextOnPath.Quadrant = cdrBottomQuadrant
End Sub
Best of luck,

-Shelby
Reply With Quote
  #3  
Old 12-01-2009, 10:40
dlpfis
Guest
 
Posts: n/a
Default

God I can't believe it's that easy! I knew i needed to use artistictext, but I couldn't find the method for fitting to path.

This helps tremendously, thanks so much.

dlpfis
Reply With Quote
  #4  
Old 16-09-2010, 04:29
blotfib
Guest
 
Posts: n/a
Default place txt in the third and middle of the curve

Hi

I want to place my text in the middle and in the third of a generated curve (I use C++, but VBA code will help me)

Code:
	crv = doc->CreateCurve();				// Create Curve object
	spath = crv->CreateSubPath(-20,50);
	spath->AppendCurveSegment( 20, 50, 20, 45, 20, 135, false);
	spath->Closed = false;
	sh = doc->ActiveLayer->CreateCurve(crv);					// Create curve shape

	shText = doc->ActiveLayer->CreateArtisticText( 0, 60, FajrText,
		CorelDRAW::cdrArabic, CorelDRAW::cdrCharSetArabic, "Times New Roman", 10, CorelDRAW::cdrFalse, CorelDRAW::cdrFalse, CorelDRAW::cdrNoFontLine, CorelDRAW::cdrCenterAlignment );

	shText->Text->FitToPath( sh);

	shText->Effects->TextOnPathEffect->TextOnPath->Quadrant= CorelDRAW::cdrBottomQuadrant;
//	shText->Effects->TextOnPathEffect->TextOnPath->PlaceOnOtherSide = true;
//	shText->Effect->TextOnPath->DistanceFromPath = 2;
By the way, I tried to find the correct syntax in using Effects or Effect, but none works :-(

thanks for your kind help
Reply With Quote
  #5  
Old 16-09-2010, 08:02
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,782
Blog Entries: 11
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Text on Path

Quadrant can only be used on a closed Path, since you are working with an open path you need to use Placement. Here is the VBA version:
Code:
Sub MoreFitText()
    Dim crv As Curve, sp As SubPath, sArc As Shape
    Dim sText As Shape, eff As Effect

    ActiveDocument.Unit = cdrMillimeter
    
    Set crv = Application.CreateCurve(ActiveDocument)
    Set sp = crv.CreateSubPath(-20, 50)
    sp.AppendCurveSegment 20, 50, 20, 45, 20, 135, False
    sp.Closed = False
    Set sArc = ActiveLayer.CreateCurve(crv)
    
    Set sText = ActiveLayer.CreateArtisticText(0, 60, "My Sample String of Text", , , "Times New Roman", 10, , , , cdrCenterAlignment)

    Set eff = sText.Text.FitToPath(sArc)
    eff.TextOnPath.PlaceOnOtherSide = True
    eff.TextOnPath.DistanceFromPath = 2
    eff.TextOnPath.Placement = cdrCenterPlacement
End Sub
If you want to place it on a third, I think you will have to do the math and set the offset. Hope it helps.

-Shelby

Last edited by shelbym; 16-09-2010 at 08:05.
Reply With Quote
  #6  
Old 17-09-2010, 04:00
blotfib
Guest
 
Posts: n/a
Default

Thanks a lot
exactly what I was looking for
here is the syntax for C++ (future ?) users :
Code:
	CorelDRAW::IDrawApplicationPtr pApp(CDR_PROGID);
	CorelDRAW::IDrawDocumentPtr doc = pApp->CreateDocument();
	CorelDRAW::IDrawPagePtr pg;
	CorelDRAW::IDrawCurvePtr crv, crva, crvb, crvc;
	CorelDRAW::IDrawSubPathPtr spath, spatha, spathb, spathc;
	CorelDRAW::IDrawShapePtr sh, shText;
	CorelDRAW::IDrawEffectPtr eff;

	doc->Unit=CorelDRAW::cdrMillimeter;
	doc->ActivePage->SetSize( PageWidth, PageHeigth);
	doc->ActiveWindow->ActiveView->SetViewPoint(PageWidth/2, PageHeigth/2, 50);	// Zoom 50%, view centrée
	doc->DrawingOriginX = 0;
	doc->DrawingOriginY = 0;

	crv = doc->CreateCurve();				// Create Curve object
	spath = crv->CreateSubPath(-20,50);
	spath->AppendCurveSegment( 20, 50, 20, 45, 20, 135, false);
	spath->Closed = false;
	sh = doc->ActiveLayer->CreateCurve(crv);					// Create curve shape

	shText = doc->ActiveLayer->CreateArtisticText( 0, 60, FajrText,
		CorelDRAW::cdrArabic, CorelDRAW::cdrCharSetArabic, "Times New Roman", 10, CorelDRAW::cdrFalse, CorelDRAW::cdrFalse, CorelDRAW::cdrNoFontLine, CorelDRAW::cdrCenterAlignment );

	eff = shText->Text->FitToPath( sh);
	//eff->TextOnPath->Quadrant= CorelDRAW::cdrBottomQuadrant;  on closed path only
	eff->TextOnPath->PlaceOnOtherSide = true;
	eff->TextOnPath->DistanceFromPath = 2;
	eff->TextOnPath->Placement = CorelDRAW::cdrCenterPlacement;
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shrink box to fit text ? bigyin General 1 09-02-2008 22:21
text tool causes app hang Corel Suite 11 BEAMA General 3 27-02-2006 18:47
Fit Text To Frame Craig Tucker CorelDRAW/Corel DESIGNER VBA 0 14-05-2004 15:52
Fit text to path: extend to the end of path dcsquare CorelDRAW/Corel DESIGNER VBA 1 26-05-2003 07:34
I can't let the text on a curve line Dino CorelDRAW/Corel DESIGNER VBA 2 11-04-2003 04:13


All times are GMT -5. The time now is 17:39.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com