unearthed Posted March 5, 2023 Share Posted March 5, 2023 I normally write my labels as a single text file (each label as a single paragraph), drag it into VW and then copy and paste out of it into single labels [I have no need or use for the call out system as it's not fit for my purpose]. Then I just drag them into position and I'm done. Is there a script (or Marionette) that will break a single text block into multiple text blocks based on eg carriage returns or space between paragraphs? Quote Link to comment
MullinRJ Posted March 6, 2023 Share Posted March 6, 2023 Hello @unearthed, I thought you would have had an answer by now. Since that didn't happen, I cobbled together a script that will split lines into text blocks. It could have more refinements, but I assume that is not necessary. Let me know if this works for you. And if you want the original text block to disappear after it is split, uncomment line 46 near the bottom. (See comments.) PROCEDURE SplitTextToLines; { Split selected text block into individual lines at each Carriage Return. Each line becomes its own text block. } { Original text block gets deleted if user uncomments the DelObject() line at the end of the script. } { 06 Mar 2023 - Raymond J Mullin } { NO WARRANTY EXPRESSED OR IMPLIED. } { USE AT YOUR OWN RISK. USE ON A COPY OF YOUR DATA FIRST. } CONST CR = chr(13); VAR H :Handle; Mirrored :Boolean; X, Y, Ang, LineSpc :Real; S, T :Dynarray of Char; BEGIN PushAttrs; H := FSActLayer; { create new text with these attributes. } TextVerticalAlign(2); { top baseline } TextJust(1); { left justified } TextSize(GetTextSize(H, 0)); { get the text, its insertion point, and the line spacing } S := GetText(H); GetTextOrientation(H, X, Y, Ang, Mirrored); LineSpc := GetTextSize(H, 0)/72; { approximate } { make sure text ends with a carriage return. } if (S[len(S)] <> CR) then S := concat(S, CR); { split lines here } while (len(S) > 0) do begin T := copy(S, 1, pos(CR, S)-1); delete(S, 1, pos(CR, S)); if (len(T) > 0) then begin MoveTo(X, Y); CreateText(T); end; Y := Y - LineSpc; end; { while } { **** Uncomment following line if you wish to delete the original text when done. **** } {DelObject(H); } PopAttrs; SysBeep; END; Run(SplitTextToLines); Raymond 2 Quote Link to comment
unearthed Posted March 6, 2023 Author Share Posted March 6, 2023 That's remarkable Raymond, I couldn't sleep and woke up to this, amazing, your script ran fine straight out of the box. Thanks for writing it. In paper space the lines are 368mm apart, how do I close them up so they're say 10mm apart? Quote Link to comment
Pat Stanford Posted March 6, 2023 Share Posted March 6, 2023 Change the denominator in the line: LineSpc := GetTextSize(H, 0)/72; { approximate } If 72 is giving 368, I would guess that something like 2100 would give you something closer to 10. 2 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.