
! script name: vsolids.d/planeparapt
! var_topic: construct plane parallel to an existing plane through a point

!A
!A NAME:
!A
!A 	Plane: Parallel Point	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows a plane to be defined through a point
!A 	parallel to an existing plane.
!A
!B INSTRUCTIONS:
!B	
!B	PICK PARALLEL PLANE: Pick the parallel plane.
!B
!B 	PICK POINT: Pick the point for the plane to pass through.
!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

Stat=ChangeLabelStr("ScriptNameStatus","Function: plane parallel pt ")

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

Var_object=CheckVarObject
IF ExitScript(Destination$) THEN Leave

ActivateUndo
Plane_loop:!
Stat=SetInputFormat("n4","")
Plane1=PickEntity("PICK PARALLEL PLANE")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Plane1) THEN Plane_loop
Stat=EntityNameCheck(Plane1,Plane$)
Etype=EntityType(Plane1)
IF NOT ((Etype=WsPlaneSolidEnt)OR(Etype=WsDiskSolidEnt)) THEN Plane_loop

Pick_point:Stat=SetInputFormat("n4=","")
E1=PickEntity("PICK POINT")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(E1) THEN Pick_point
IF NOT ValidDependency(E1) THEN Pick_point
T=LastPickPara
Pick_return=CurrPickReturn
Stat=EntityNameCheck(E1,Center$)
Pc=ParameterReturnPt(E1,T,Pick_return)
Stat=SetEqualsValue(Radius)
Stat=SetLastPoint(Pc)
Stat=DeleteEntity(Pc)

Stat=GenerateVarName(WsPlaneSolidEnt,Name$)
RecordFunctionOn
Stat=RecordDescr("PLANE: Plane Parallel Pt")
Stat= SetRecDelLastExec
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
Ps=SurfParameterPt(Plane$,0.0,0.0)
V1=VectorTwoPts(Ps,Pc)
P1=VectorCopyEntity(Plane$,V1)
Stat=NameEntity(P1,Name$)
Stat=DeleteEntityList(V1,Ps,Pe)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(P1) THEN
	DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("plane")
	Stat= AddItemToUndo(WsUBCreateMode,P1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Plane_loop

Leave:!
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
