
! script name: draft.d/textballoon
! topic: construct text in a balloon

!A
!A NAME:
!A
!A 	Text Balloon
!A
!A DESCRIPTION:
!A
!A 	This script allows a line of text to be placed inside a balloon.
!A
!B INSTRUCTIONS:
!B
!B 	INPUT ABS X,Y,Z: Enter the X,Y,Z coordinates for the starting position
!B 		of the line of text.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	INPUT TEXT LINE: Enter the line of text to be placed starting at the
!B 		specified coordinates.
!B
!C NOTE:
!C
!C 	EXTENDED CHARACTER SET: Characters may be input by their ascii number.
!C 		Type in \031 for example to use the character in the font
!C 		assigned to the ascii number 31. The code must be a three digit
!C 		number from 001 to 255.  Some of the extended characters like
!C 		the geometric tolerancing symbols take up more than one space
!C 		so they should be bracketed with extra spaces.
!C
!# see also - htdocs/help.d/dynamicdim.htm
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: text balloon ")

DIM Answer$[256]
DIM Destination$[256]
DIM Text$[256]
DEG

ActivateUndo
Start:!
Dynamic_position=1
Dim_type= WsTextBalloon
! Dim_type= WsLeaderBalloon


Dim_loop:!

Stat=SetInputFormat("a99","",0)
Stat=GetValue("INPUT TEXT",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Stat= BackSlashChars(Answer$,Text$)

Pick_point:IF Dynamic_position THEN
        Pstart= PointXYZ(0,0,0)
ELSE
	Stat=SetInputFormat("n4","")
        Pstart=XyzInput("BALLOON CENTER",WsXyOnly)
        IF (ExitScript(Destination$)) THEN Leave
        IF NOT ValidGeometry(Pend) THEN Pick_point
END IF

PlotOff
E1= TextBalloon(Dim_type,Text$,Pstart)
PlotOn
Stat=EditDraftSetting(E1,WsArrowsOn,0,0)
Stat=EditDraftSetting(E1,WsLeaderOn,0,1)
Stat=DeleteEntity(Pstart)

IF Dynamic_position THEN
        Which_end=1
        Vnum= LastPickView
        Stat= DynamicDimEdit(Vnum,E1,Which_end,"PICK BALLOON CENTER",WsFalse)
	IF (ExitScript(Destination$)) THEN
                Stat= DeleteEntity(E1)
                GOTO Leave
        END IF
END IF

ActivateUndo
Stat= AdvanceUndoNumber("balloon")
Stat= AddDimToUndo(WsUBCreateMode,E1)

GOTO Dim_loop

Leave:!
Stat=SetInputFormat("n4","")
Stat=DeleteEntity(Pstart)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	IF Destination$= "SCRIPTSTART" THEN Start
        IF Destination$= "BACKUP" THEN Start
	 LOAD Destination$
END IF
END
