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
MarcelP102 Posted September 9, 2024 Share Posted September 9, 2024 (edited) @MullinRJ @Pat Stanford Sorry to hack this thread I have a 2d objects with attached records. It has a field 'WaardeType' contains multiple value split with a ','. The 'waarde' field contains the corresponding values split with a ','. In the screenshot below it are two values, but this could be even more or less. Its different per object. I want a newly placed symbol to have values of the field values of the 2d object. I already gave the symbol the record '9)omgevingsplan' with field 'maximum goothoogte (m)' etc. How do I transfer the corresponding '2' to replace 'x' I think I can use your script to split one row. But how would I split one field and use that as field name to transfer the corresponding value (that also needs splitting)? It's hard to explain for me, so I made a doodle: sometimes it's only one value: The ultimate goal is to create all these symbols and use the split value to change the text Any help would be appreciated Edited September 9, 2024 by MarcelP102 Quote Link to comment
MarcelP102 Posted September 9, 2024 Share Posted September 9, 2024 Nevermind, got it working! Thanks Raymond for the example! 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.