
! script name: vlines.d/parallel
! var_topic: construct line parallel at specified perpendicular distance

!A
!A NAME:
!A
!A 	Parallel Line	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script constructs a line parallel to another line at a
!A 	specified perpendicular distance.
!A
!A~ image location - images/parallelline.jpg
!B INSTRUCTIONS:
!B
!B 	PARALLEL DISTANCE: The perpendicular distance between
!B 		the original line and the line that will be
!B 		constructed parallel to it.
!B
!B 	PICK PARALLEL LINE: Pick the line referenced for
!B 		the parallel distance.  This line has already been
!B 		described.  It cannot be described in this script.
!B
!B 	PICK LEFT/RIGHT OF LINE: This indicates the side the
!B 		parallel line will be constructed on.
!B

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

DIM Destination$[256]
DIM Answer$[256]
DIM Lname$[256]
DIM Name$[256]
DIM Dist_var$[256]

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

Distr=NamedVarVal("parallel distance",WsSystemVars,.25)

ActivateUndo
Line_loop:!
Stat=SetEqualsValue(Distr)
Stat=SetInputFormat("n4=","")

Distance=GetValue("PARALLEL DISTANCE",Answer$)
IF (ExitScript(Destination$)) THEN Leave

No_dist_var= LastVariableInput(Dist_var$)

Distr=Distance



Pick_line:!
Stat=SetInputFormat("n4a1",",N,")
E1=PickEntity("PICK PARALLEL LINE, New distance",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$= "N" THEN Line_loop
IF NOT ValidDependency(E1) THEN Pick_line
Stat= EntityNameCheck(E1,Lname$)
Etype= EntityType(E1)
IF Etype<> WsLineEnt THEN Pick_line


Pt=InputFreePoint("PICK LEFT/RIGHT OF LINE")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Pt) THEN Line_loop

S1=PtLeftRight(E1,Pt)
Stat=DeleteEntity(Pt)

Stat= GenerateVarName(WsLineEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("LINE: Parallel")
Stat= SetRecDelLastExec
IF No_dist_var THEN
	V1= FreeParameter("Distance",Distance)
	L1=Parallel(Lname$,V1,WsUNTRIMMED,S1)
ELSE
	L1=Parallel(Lname$,Dist_var$,WsUNTRIMMED,S1)
END IF
Stat= NameEntity(L1,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

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

ActivateUndo
Stat= AdvanceUndoNumber("parallel line")
Stat= AddItemToUndo(WsUBCreateMode,L1)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
GOTO Pick_line

Leave:!
Vdist=CreateVariable("parallel distance",WsSystemVars,Distr)
Stat=SetInputFormat("n4","")

Stat=DeleteEntity(Pt)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END

