
! script name: vlines.d/bisector
! var_topic: construct angular bisector of two intersecting lines

!A
!A NAME:
!A
!A 	Bisector (angular)	--- VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script constructs the line which is the angular bisector of
!A 	two intersecting lines.  No line will be constructed if the same
!A 	line is picked or if two parallel lines are picked.
!A
!A~ image location - images/bisector.jpg
!B INSTRUCTIONS:
!B
!B 	PICK FIRST LINE: Pick one of the two intersecting lines.
!B
!B 	PICK NEXT LINE: Pick the other line.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: bisector (angular) ")

DIM Destination$[256]
DIM Answer$[256]
DIM Name1$[256]
DIM Name2$[256]
DIM Name$[256]


Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

ActivateUndo
DEG
stat= SetInputFormat("n4","")

Line_loop:!
L1=PickSpecificEnt("PICK FIRST LINE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(L1) THEN Line_loop
Stat= EntityNameCheck(L1,Name1$)
P1=LastPickPoint

Pick_line2:L2=PickSpecificEnt("PICK NEXT LINE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(L2) THEN Pick_line2
Stat= EntityNameCheck(L2,Name2$)
P2=LastPickPoint

Sign1=PtLeftRight(L1,P2)
Sign2=PtLeftRight(L2,P1)
Stat=DeleteEntity(P1)
Stat=DeleteEntity(P2)

Stat= GenerateVarName(WsLineEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("LINE: Angle Bisector")
Stat= SetRecDelLastExec
Ln1=BisectorLine(Name1$,Sign1,Name2$,Sign2,WsUNTRIMMED)
Stat= NameEntity(Ln1,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= PlotEntity(Name1$)
Stat= PlotEntity(Name2$)
Stat= PlotEntity(Ln1)
IF NOT ValidGeometry(Ln1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("bisector line")
	Stat= AddItemToUndo(WsUBCreateMode,Ln1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Line_loop

Leave:!
Stat=SetXyzInput(WsXyzInput)
Stat=DeleteEntity(P1)
Stat=DeleteEntity(P2)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END


