
! script name: lines.d/parataper
! topic: construct line parallel at specified taper angle and height

!A
!A NAME:
!A
!A 	Parallel Taper Line
!A
!A DESCRIPTION:
!A
!A 	This script constructs a line parallel to another line at a
!A 	taper angle and height.
!A
!B INSTRUCTIONS:
!B
!B	HEIGHT: Specify the height. + up, - down.
!B
!B 	TAPER ANGLE: Specify the taper angle.  
!B
!B 	PICK PARALLEL LINE: Pick the line referenced for the parallel
!B 		distance.  This line has already been described.  It cannot
!B 		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


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

Z_height=GetValue("HEIGHT",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Taper_angle: Taper_angle=InputAngle("TAPER ANGLE")
IF (ExitScript(Destination$)) THEN Leave

Pick_line: 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)

Dist= S1*ABS(Z_height*TAN(Taper_angle))

L1=Parallel(E1,Dist,WsUNTRIMMED)

Pz=PointXYZ(0.0,0.0,Z_height)
T1=AngleTransform(Pz,0,0,0,WsWorkplaneVals)
L2=TransformEntity(L1,T1)

Stat=DeleteEntity(Pt)
Stat=DeleteEntity(Pz)
Stat=DeleteEntity(L1)
Stat= PlotEntity(L2)

ActivateUndo
Stat= AdvanceUndoNumber("line")
Stat= AddItemToUndo(WsUBCreateMode,L2)
GOTO Taper_angle

Leave:!
Stat=SetInputFormat("n4","")
Stat=DeleteEntity(Pt)
Stat=DeleteEntity(Pz)
Stat=DeleteEntity(L1)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
