Jump to content

Combine multiple text boxs into 1 text box


Recommended Posts

Ive just imported a dwg that was converted from a pdf (not the best workflow i know) each line in what was originally one large text box has been pulled off into separate text boxs, is there a simple way i can re combine them (with out having to cut and paste each line into a new text box)

Link to comment

The following is a script that I wrote a few years ago for this case. Although it was done back in VW8, I tested it on VW2014 and still works without changes so it should work on any version since then.

It works by running the script and clicking on the text to be added first and then on the text receiving it.

When you hover over a text object, the cursor should change and the text should turn red. You can continue clicking and adding text lines to the master text block without invoking the script again and the script will end when you click on an empty space.

PROCEDURE AppendText;
{DEBUG}
VAR
sourceClass,targetClass: STRING;
sourceHdl,targetHdl: HANDLE;
sRed,sGrn,sBlu,tRed,tGrn,tBlu: LONGINT;
sourceTxt,targetTxt: DYNARRAY[] of CHAR;

FUNCTION GetTextHdl(VAR objClass: STRING; objR,objG,objB: LONGINT): HANDLE;
VAR
	oldClass: STRING;
	objHdl,oldHdl: HANDLE;
	pX,pY,mx,my: REAL;
	red,green,blue:LONGINT;
BEGIN
oldHdl:= NIL;
REPEAT
	GetMouse(pX,pY);
	objHdl:= PickObject(pX,pY);
	IF (objHdl<> NIL) & (GetType(objHdl) = 10) THEN
		BEGIN
		IF objHdl <> oldHdl THEN
			BEGIN
			IF oldHdl <> NIL THEN
				BEGIN
				IF Len(oldclass) > 0 THEN
					BEGIN
					SetPenColorByClass(oldHdl);
					SetClass(oldHdl,oldClass);
					END
				ELSE
					SetPenFore(oldHdl,red,green,blue);
				END;

			oldClass:= '';
			IF IsPenColorByClass(objHdl) THEN
				oldClass:= GetClass(objHdl)
			ELSE
				GetPenFore(objHdl,red,green,blue);	
			SetPenFore(objHdl,65535,0,0);	
			oldHdl:= objHdl;
			Redraw;
			END;
		SetCursor(SmCrossC);
		END
	ELSE
		BEGIN
		IF oldHdl <> NIL THEN
			BEGIN
			IF Len(oldClass) > 0 THEN
				BEGIN
				SetPenColorByClass(oldHdl);
				SetClass(oldHdl,oldClass);
				END
			ELSE
				SetPenFore(oldHdl,red,green,blue);
			Redraw;
			END;
		oldHdl:= NIL;
		SetCursor(ArrowC);
		END;
UNTIL MouseDown(mx,my);

objHdl:= PickObject(pX,pY);
IF objHdl <> NIL THEN
	BEGIN
	IF GetType(objHdl) = 10 THEN
		BEGIN
		objClass:= oldClass;
		objR:= red;
		objG:= green;
		objB:= blue;	
		END
	ELSE
		objHdl:= NIL;
	END;
GetTextHdl:= objHdl;
END;
BEGIN
REPEAT
sourceHdl:= GetTextHdl(sourceClass,sRed,sGrn,sBlu);
IF (sourceHdl <> NIL) THEN
	BEGIN
	sourceTxt:= GetText(sourceHdl);
	targetHdl:= GetTextHdl(targetClass,tRed,tGrn,tBlu);
	IF (targetHdl = NIL) THEN
		BEGIN
		IF Len(sourceClass) > 0 THEN
			BEGIN
			SetPenColorByClass(sourceHdl);
			SetClass(sourceHdl,sourceClass);
			END
		ELSE
			SetPenFore(sourceHdl,sRed,sGrn,sBlu);
		Redraw;
		END
	ELSE IF GetType(targetHdl) = 10 THEN
		BEGIN
		targetTxt:= GetText(targetHdl);
		targetTxt:= Concat(targetTxt,Chr(13),sourceTxt);
		IF Len(targetClass) > 0 THEN
			BEGIN
			SetPenColorByClass(targetHdl);
			SetClass(targetHdl,targetClass);
			END
		ELSE
			SetPenFore(targetHdl,tRed,tGrn,tBlu);
		SetText(targetHdl,targetTxt);
		DelObject(sourceHdl);
		Redraw;
		END
	ELSE
		targetHdl:= NIL;
	END
ELSE
	sourceHdl:= NIL;
UNTIL (sourceHdl = NIL) | (targetHdl = NIL);
END;
Run(AppendText);

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...