
! script name: zplanes.d/vertlineplane
! topic: define workplane vertical to line in standard workplane

!A
!A NAME:
!A
!A 	Vertical to Line
!A
!A DESCRIPTION:
!A
!A 	This script allows a workplane to be made vertical to a line in the
!A 	standard workplane.  This is useful for cross sections in 3D.
!A
!B INSTRUCTIONS:
!B
!B 	PICK LINE FOR WORKPLANE AXIS: Pick the line to be used as a reference
!B 		for the new workplane.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: vertical to line ")

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

Start:StdWorkplane
stat= SetInputFormat("n4","")

L1=PickSpecificEnt("PICK LINE FOR WORKPLANE AXIS",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
T= LastPickPara
IF T< 0.5 THEN
	T1= 0.0
	T2= 1.0
ELSE
	T1= 1.0
	T2= 0.0
END IF

P1= ParameterPt(L1,T1)
P2= ParameterPt(L1,T2)

X= XPointValue(P1)
Y= YPointValue(P1)
Z= ZPointValue(P1)

Z= Z+ 1.0

P3= PointXYZ(X,Y,Z)

Work=ThreePtTrans(P1,P2,P3)
IF NOT ValidGeometry(Work) THEN
	Stat=DeleteEntity(P1)
	Stat=DeleteEntity(P2)
	Stat=DeleteEntity(P3)
	GOTO Start
END IF

Stat=SetWorkplane(Work)
IF IsRulerOn THEN PlotAll

WplaneEnt= FindNamedVar("current work area",123456)
IF ValidGeometry(WplaneEnt) THEN Stat= DeleteEntity(WplaneEnt)

Leave:!
Stat=DeleteEntity(P1)
Stat=DeleteEntity(P2)
Stat=DeleteEntity(P3)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
