
! script name: solids.d/normalplane
! 3dtopic: construct plane normal to a curve element

!A
!A NAME:
!A
!A 	Plane: Normal Element
!A
!A DESCRIPTION:
!A
!A 	This script will construct a plane of specified length and width, 
!A 	normal to an entity at a point.
!A
!B INSTRUCTIONS:
!B
!B 	X LENGTH: Enter the length of the plane measured
!B 		along the X axis.
!B
!B 	Y LENGTH: Enter the length of the plane measured
!B 		along the Y axis.
!B
!B 	TILT ANGLE: This represents the angle of tilt around
!B 		the tangent vector of the plane.
!B
!B 	PICK NORMAL ENTITY: Pick the element that defines
!B 		the planes normal.
!B
!B 	INPUT ABS X,Y,Z: Enter the X,Y,Z coordinates of the
!B 		point, through which the plane will be constructed.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!C NOTES:
!C
!C 	The U contours of a plane are the lines parallel to the length of
!C 	the plane ( parallel to X axis in an unoriented plane ) and the V
!C 	contours are the lines parallel to the width of the plane ( parallel
!C 	to Y axis in an unoriented plane ).
!C
!# see also - points.d/xyzinput.hlp

Stat=ChangeLabelStr("ScriptNameStatus","Function: normal plane ")

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

ActivateUndo
Xlength= 5
Ylength= 5

Cloop:!

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Xlength)
XLength=GetValue("X LENGTH",Answer$)
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Ylength)
YLength=GetValue("Y LENGTH",Answer$)
IF ExitScript(Destination$) THEN Leave

Stat=SetAngleEquals(Tilt_angle)
Tilt_angle=InputAngle("TILT ANGLE ",WsSigned)
IF ExitScript(Destination$) THEN Leave

Pick_loop:Stat=SetInputFormat("n4","")
Stat=SetPickMask(WsPickNoSurf)
E1=PickEntity("PICK NORMAL ENTITY")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(E1) THEN Pick_loop
Stat=SetPickMask(WsPickAll)

Pt=XyzInput("INPUT",WsXyzInput)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Pt) THEN Pick_loop

On_center=1
Axis_line=TangentLine(E1,Pt,WsTRIMMED)
P1=AxisLinePlane(Axis_line,Xlength,Ylength,Tilt_angle,On_center,WsForward)
Stat=DeleteEntity(Axis_line)
Stat=DeleteEntity(Pt)

ActivateUndo
Stat= AdvanceUndoNumber("plane")
Stat= AddItemToUndo(WsUBCreateMode,P1)
GOTO Pick_loop

Leave:!
Stat=SetPickMask(WsPickAll)
Stat=SetInputFormat("n4","")
Stat=DeleteEntity(Pt)
Stat=DeleteEntity(Axis_line)

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