
! script name: zplanes.d/lineverttrans
! var_topic: define workplane normal to line

!A
!A NAME:
!A
!A 	Workplane: Pt: Normal Line
!A
!A DESCRIPTION:
!A
!A 	This script allows a workplane to be made normal to a line.
!A
!B INSTRUCTIONS:
!B
!B 	WORKPLANE ZERO ABS X,Y,Z: Enter the X,Y,Z coordinates
!B 		of the point to be used as the reference point
!B 		for making the new workplane.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B 	PICK LINE NORMAL TO WORKPLANE: Pick the line that will
!B 		be perpendicular to the new workplane.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: workplane: pt: normal 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
stat= SetInputFormat("n4","")

Center_point: E1=PickEntity("PICK WORKPLANE ZERO")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Center_point
T= LastPickPara
Pick_return= CurrPickReturn
Stat= EntityNameCheck(E1,Center$)

Pick_line:L1=PickSpecificEnt("PICK LINE NORMAL TO WORKPLANE",WsPickLines)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(L1) THEN Pick_line
Stat= EntityNameCheck(L1,Element$)


Stat= GenerateVarName(WsTransformEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("WORKPLANE: point, normal to line")
Stat=SetWorkplane
SELECT Pick_return
CASE WsGeometryEnd
        Pc= ParameterReturnPt(Center$,T,WsGeometryEnd)
CASE WsGeometryMid
        Pc= ParameterReturnPt(Center$,T,WsGeometryMid)
CASE WsGeomCenter
        Pc= ParameterReturnPt(Center$,T,WsGeomCenter)
END SELECT
Trans1=LineToVertTrans(Element$,Pc)
Stat=SetWorkplane(Trans1)
Stat= NameEntity(Trans1,Name$)
Stat=DeleteEntity(Pc)
RecordFunctionOff
CloseVarRecord

Stat= PlotEntity(Center$)
IF IsRulerOn THEN PlotAll

Leave:!
stat= SetInputFormat("n4","")

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

