
! script name: vlines.d/ptangleline
! var_topic: construct line through point at angle to a line

!A
!A NAME:
!A
!A 	Point: Angle: Line  VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script constructs a line through a point at a specified angle
!A 	to another line.  The other line has already been defined.
!A
!A~ image location - images/ptangleline.gif
!A
!B INSTRUCTIONS:
!B
!B 	INPUT ABS X,Y,Z: Enter the X,Y,Z coordinates of the point, through
!B 		which the line will be constructed at the specified angle
!B 		to another line.  NOTE: See XYZ INPUT OPTIONS.
!B
!B 	ANGLE OF LINE: Enter the angle of the line to be constructed.
!B
!B 	PICK LINE: Pick the line to be used as the reference for the
!B 		specified angle.
!B
!# see also - points.d/xyzinput.hlp

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

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

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

ActivateUndo
DEG
Line_loop:Stat=SetInputFormat("n4","")
E1=PickEntity("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

Pick_line:Eline=PickSpecificEnt("PICK LINE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Eline) THEN Pick_line
Stat= EntityNameCheck(Eline,Lname$)


Stat=DeleteEntity(Pc)

Stat= GenerateVarName(WsLineEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("LINE: Point at angle to line")
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)
        Ln1=PtAngleLine(Pc,V1,Lname$)
ELSE
        Ln1=PtAngleLine(Pc,Angle_var$,Lname$)
END IF
Stat= NameEntity(Ln1,Name$)
Stat=DeleteEntity(Pc)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= PlotEntity(Ln1)
Stat= PlotEntity(Center$)

ActivateUndo
Stat= AdvanceUndoNumber("pt angle line")
Stat= AddItemToUndo(WsUBCreateMode,Ln1)
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


