
! script name: vnvars.d/vangtwolines
! var_topic: make variable for angle between two lines

!A
!A NAME:
!A
!A 	Angle Two Lines
!A
!A DESCRIPTION:
!A
!A 	This script makes a variable dependent on the angle between two lines.
!A
!B INSTRUCTIONS:
!B
!B 	VARIABLE NAME: Enter the variable name.
!B
!B 	INVALID VARIABLE NAME: Name input was invalid choose new variable.
!B
!B 	STARTING LINE: Select the starting line.
!B
!B 	ENDING LINE: Select the ending line.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: make angle two lines variable")

DIM Answer$[256]
DIM Name$[256]
DIM Descr$[256]
DIM Element$[256]
DIM Destination$[256]
DIM Line1$[256]
DIM Line2$[256]
DEG

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

DeActivateUndo
Name_loop:!
stat= SetInputFormat("a99","")
Stat=GetValue("VARIABLE NAME",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Name$= Answer$
IF NOT ValidVariableName(Name$)	THEN
	stat= SetInputFormat("a99","")
	Stat=GetValue("INVALID VARIABLE NAME, Proceed",Answer$)
	IF (ExitScript(Destination$)) THEN Leave
	GOTO Name_loop
END IF



stat= SetInputFormat("n4","")
Pick_start:E1=PickSpecificEnt("STARTING LINE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_start
Stat= EntityNameCheck(E1,Line1$)

Pick_end:!
E2=PickSpecificEnt("ENDING LINE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E2) THEN Pick_end
Stat= EntityNameCheck(E2,Line2$)


RecordFunctionOn
Stat= RecordDescr("VARIABLE: Angle between two lines")
V1=NumericVariable(Name$,WsVariationVars,AngleTwoLines(Line1$,Line2$))
stat= SetVariableDescr(V1,"Angle Two Lines:")
RecordFunctionOff
CloseVarRecord

GOTO Name_loop



Leave:!
stat= SetInputFormat("n4","")
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
