
! script name: vnvars.d/vangle
! var_topic: make angle variable

!A
!A NAME:
!A
!A 	Make Angle Variable
!A
!A DESCRIPTION:
!A
!A 	This script will make a variable dependent on the angle of a line.
!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 	PICK LINE FOR ANGLE: Pick the line which defines the angle.
!B

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

DIM Answer$[256]
DIM Name$[256]
DIM Descr$[256]
DIM Element$[256]
DIM Destination$[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


Pick_loop:Stat=SetInputFormat("n4","")
E1=PickSpecificEnt("PICK LINE FOR ANGLE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_loop
Stat= EntityNameCheck(E1,Element$)


RecordFunctionOn
Stat= RecordDescr("VARIABLE: Line angle")
V1=NumericVariable(Name$,WsVariationVars,LineAngle(Element$))
stat= SetVariableDescr(V1,"Angle:")
RecordFunctionOff
CloseVarRecord

GOTO Name_loop



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