Jump to content
Developer Wiki and Function Reference Links ×

Splitting a single text object into multiple text objects


Recommended Posts

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?

Link to comment

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

  • Like 2
Link to comment
  • 1 year later...

@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:
 

Helpwithsplit.thumb.png.3f2b8a2dec15c73909b9e8cb081a26a5.png

 

sometimes it's only one value:

image.png.e033f8d857f877ad66e19af0265fd64a.png

 

The ultimate goal is to create all these symbols and use the split value to change the text

image.png.62418c2a8e528b05ab6aafecac0e1ff2.png

 

Any help would be appreciated

 

Edited by MarcelP102
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...