
! script name: lines.d/vartaper
! topic: construct line at specified taper angles and height

!A
!A NAME:
!A
!A 	Variable 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 LINE: Pick the line referenced for the parallel distance.
!B 		This line has already been described.  It cannot be described
!B 		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_angle1: Taper_angle1=InputAngle("START TAPER")
IF (ExitScript(Destination$)) THEN Leave

Taper_angle2: Taper_angle2=InputAngle("END TAPER")
IF (ExitScript(Destination$)) THEN Leave

Pick_line: E1=PickSpecificEnt("PICK LINE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(E1) THEN Line_loop

T1= LastPickPara
IF T1> 0.5 THEN
	Temp= Taper_angle1
	Taper_angle1= Taper_angle2
	Taper_angle2= Temp
END IF

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_angle1))
L1=Parallel(E1,Dist,WsTRIMMED)
P1= ParameterPt(L1,0.0)

Dist= S1*ABS(Z_height*TAN(Taper_angle2))
L2=Parallel(E1,Dist,WsTRIMMED)
P2= ParameterPt(L2,1.0)

L3= LineTwoPoints(P1,P2,WsTRIMMED)
Stat=DeleteEntity(L1)
Stat=DeleteEntity(L2)
Stat=DeleteEntity(P1)
Stat=DeleteEntity(P2)



Pz=PointXYZ(0.0,0.0,Z_height)
T1=AngleTransform(Pz,0,0,0,WsWorkplaneVals)
Taper_line=TransformEntity(L3,T1)

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

Stat= PlotEntity(Taper_line)
ActivateUndo
Stat= AdvanceUndoNumber("line")
Stat= AddItemToUndo(WsUBCreateMode,Taper_line)

GOTO Taper_angle1

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