
! script name: vlines.d/ptparallel
! var_topic: construct line parallel to another line through a point.

!A
!A NAME:
!A
!A 	Line Parallel Through a Point  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
!B INSTRUCTIONS:
!B
!B 	INPUT ABS X,Y,Z: Enter the X,Y,Z coordinates of the
!B 		point, through which the line will be constructed
!B 		at the specified angle to another line.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B 	PICK LINE: Pick the line to be used as the parallel.
!B
!# see also - points.d/xyzinput.hlp

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

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


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



Stat= GenerateVarName(WsLineEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("LINE: Parallel through a point")
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
L1=PointParallel(Pc,Lname$)
Stat= NameEntity(L1,Name$)
Stat=DeleteEntity(Pc)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= PlotEntity(Center$)
Stat= PlotEntity(Lname$)
Stat= PlotEntity(L1)

ActivateUndo
Stat= AdvanceUndoNumber("parallel line")
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


