
! script name: lines.d/parallel
! topic: construct line parallel at specified perpendicular distance

!A
!A NAME:
!A
!A 	Parallel Line
!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 the
!B 		original line and the line that will be constructed
!B 		parallel to it.
!B
!B 	PICK PARALLEL LINE: Pick the line referenced for the parallel
!B 		distance.  This line has already been described.  It 
!B 		cannot be described in this script.
!B
!B 	PICK LEFT/RIGHT OF LINE: This indicates the side the parallel
!B 		line will be constructed on.
!B

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

DIM Destination$[256]
DIM Answer$[256]

DEG

Distance=NamedVarVal("parallel distance",WsSystemVars,.25)
Ask_dist=NamedVarVal("ask parallel dist",WsSystemVars,0.0)
Trimmed_line=0

ActivateUndo
Ask_distance:!
IF Ask_dist THEN
   Stat=SetEqualsValue(Distance)
   Stat=SetInputFormat("n4=","")
   Distance=GetValue("PARALLEL DISTANCE",Answer$)
   IF (ExitScript(Destination$)) THEN Leave
END IF
Line_length= GetDefault(WsLineLength)

Line_loop:!
Stat=DynLabel("Distance:"&VAL$(Distance)&":Length:"&VAL$(Line_length))
E1=PickSpecificEnt("PICK PARALLEL LINE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(E1) THEN Line_loop

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)

Distance= DynBufferValue(0,Distance)
Line_length= DynBufferValue(1,Line_length)
Dist=S1*Distance
IF Line_length<=0 THEN
     L1=Parallel(E1,Dist,WsTRIMMED)
ELSE
     L1=Parallel(E1,Dist,WsUNTRIMMED,1,Line_length)
END IF

ActivateUndo
Stat= AdvanceUndoNumber("line")
Stat= AddItemToUndo(WsUBCreateMode,L1)
Vdist=CreateVariable("parallel distance",WsSystemVars,Distance)
GOTO Line_loop

Leave:!
Stat=DynLabel("")

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