
! script name: vzplanes.d/vertlineplane
! var_topic: define workplane vertical to line in standard workplane

!A
!A NAME:
!A
!A 	Vertical to Line	VARIATIONAL
!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
!B 		used as a reference for the new workplane.
!B

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

DIM Answer$[256]
DIM Destination$[256]
DIM Element$[256]
DIM Name$[256]
DIM Center$[256]

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

DeActivateUndo
Start:!
stat= SetInputFormat("n4","")

Pick_line:L1=PickSpecificEnt("PICK LINE OR WORKPLANE AXIS",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(L1) THEN Pick_line
Stat= EntityNameCheck(L1,Element$)
T= LastPickPara
IF T< 0.5 THEN
	T1= 0.0
	T2= 1.0
ELSE
	T1= 1.0
	T2= 0.0
END IF

Stat= GenerateVarName(WsTransformEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("WORKPLANE: vertical to a line")
Stat=SetWorkplane
Pc= ParameterPt(Element$,T1)
P1= ParameterPt(Element$,T2)
Pz= PointXYZ(0.0,0.0,1.0)
P2= AddVectors(P1,Pz)
Trans1=ThreePtTrans(Pc,P1,P2)
Stat=SetWorkplane(Trans1)
Stat= NameEntity(Trans1,Name$)
Stat=DeleteEntityList(Pc,Pz,P1,P2)
RecordFunctionOff
CloseVarRecord

Stat= PlotEntity(Element$)
IF IsRulerOn THEN PlotAll

Leave:!
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
