
! script name: draft.d/cutplaneline
! topic: construct cutting plane line

!A
!A NAME:
!A
!A 	Cutting Plane Line
!A
!A DESCRIPTION:
!A
!A 	This script constructs cutting plane line with a label.
!A
!B INSTRUCTIONS:
!B
!B 	START ABS X,Y: Enter the X,Y coordinates for the start of the
!B 		line.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	END ABS X,Y: Enter the X,Y coordinates for the end of the line.
!B
!B 	INPUT LABEL: Enter the label to be associated with the line.
!B
!C
!C NOTE:
!C
!C      The labels may be located in three dirrerent places.
!C      This is controled by the parameter Label location.
!C      A value of 1 puts the labels at the ends of the arrows.
!C      A value of 2 puts the labels below the cutting plane line.
!C      A value of 3 puts the labels at the ends of the cutting plane line.
!C      Values of 11,12,13 give only the left half configuration.
!C      Values of 21,22,23 give only the right half configuration.
!C
!# see also - htdocs/help.d/dynamicdim.htm
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: cutting plane line ")

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

ActivateUndo
Start:!
Dynamic_position=1
Dim_type= WsCuttingPlaneLine
New_line$= "\n"
End_line$= CHR$(10)
Text_height= GetDefault(WsTextHeight)
Text_width= GetDefault(WsTextWidth)
Arrow_height= GetDefault(WsArrowHeight)
Arrow_width= GetDefault(WsArrowWidth)
Text_scale= 3.0
Label_location= 1



Dim_loop:! 
stat= SetInputFormat("a99","")
stat= GetValue("INPUT LABEL, None ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
SELECT Answer$
CASE "N", "n", "None","NONE"
	Text$=""
CASE ELSE
	Stat= BackSlashChars(Answer$,Text1$)
	Stat= ReplaceString(Text1$,New_line$,End_line$,Text$)
END SELECT


stat= SetInputFormat("n4","")
Pstart=XyzInput("START",WsXyOnly)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pstart) THEN Dim_loop

IF Dynamic_position THEN
	Pend= PointXYZ(0,0,0)
ELSE
	Pend=XyzInput("END",WsXyOnly)
	IF (ExitScript(Destination$)) THEN Leave
	IF NOT ValidGeometry(Pend) THEN Dim_loop
END IF


PlotOff
Height= 2.0*Text_scale*Text_height
Side= WsLeft
E1= CuttingPlaneLine(Dim_type,Pstart,Pend,Height,Label_location,8,Side,Text$,Text_scale)
PlotOn
Stat=SetLastPoint(Pend)
Stat=DeleteEntity(Pstart)
Stat=DeleteEntity(Pend)

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

ActivateUndo
Stat= AdvanceUndoNumber("cutting plane line")
Stat= AddDimToUndo(WsUBCreateMode,E1)
GOTO Dim_loop

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