
! script name: vlines.d/ptangle
! var_topic: construct line through xyz point at angle

!A
!A NAME:
!A
!A 	Point Angle   VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script will construct a line through a point, at a
!A 	specified angle.
!A
!A~ image location - images/ptangle.jpg
!B INSTRUCTIONS:
!B
!B 	ANGLE: Enter the angle of the line that will be constructed through
!B 		the defined point.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: point angle ")

DIM Answer$[256]
DIM Center$[256]
DIM Destination$[256]
DIM Name$[256]
DIM Angle_var$[256]

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


ActivateUndo
Line_loop:Stat=SetInputFormat("n4","")
E1=PickEntity("PICK POINT")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Line_loop
Stat= EntityNameCheck(E1,Center$)
T= LastPickPara
Pick_return= CurrPickReturn
Pc= ParameterReturnPt(E1,T,Pick_return)

Angle_ques:Angle=InputAngle("ANGLE")
IF (ExitScript(Destination$)) THEN Leave
No_angle_var= LastVariableInput(Angle_var$)
L1= LastPickEnt
IF ValidGeometry(L1) THEN
	IF NOT ValidDependency(L1) THEN Angle_ques
	Stat= EntityNameCheck(L1,Angle_var$)
        No_angle_var=0
END IF
Stat= DeleteEntity(Pc)

Stat= GenerateVarName(WsLineEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("LINE: Point angle")
Stat= SetRecDelLastExec
SELECT Pick_return
CASE WsGeometryEnd
	Pc= ParameterReturnPt(Center$,T,WsGeometryEnd)
CASE WsGeometryMid
	Pc= ParameterReturnPt(Center$,T,WsGeometryMid)
CASE WsGeomCenter
	Pc= ParameterReturnPt(Center$,T,WsGeomCenter)
END SELECT
IF No_angle_var THEN
	V1= FreeParameter("Angle",Angle)
	L1=PointAngle(Pc,V1)
ELSE
	L1=PointAngle(Pc,Angle_var$)
END IF
Stat= NameEntity(L1,Name$)
Stat= DeleteEntity(Pc)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= PlotEntity(Center$)
Stat=SetEqualsValue(Angle)
Stat= PlotEntity(L1)

ActivateUndo
Stat= AdvanceUndoNumber("line pt angle")
Stat= AddItemToUndo(WsUBCreateMode,L1)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Line_loop

Leave:!
Stat= DeleteEntity(Pc)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END

