
! script name: vzplanes.d/zxturningplane
! var_topic: define workplane for zx turning on a horizontal mill.

!A
!A NAME:
!A
!A 	Workplane: ZX Turning Plane   VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script defines a workplane for ZX turning on a horiz mill.
!A
!B INSTRUCTIONS:
!B
!B 	CENTER POINT ABS X,Y,Z: Enter the X,Y,Z
!B 		coordinates for the center point.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!B
!C NOTES:
!C
!C	This script is to be used for a horizontal milling machine equiped 
!C	with a special turning head to setup a workplane for turning 
!C	applications. 
!C
!C	The center point will determine the zero point for the turning
!C	cycles.
!C      To use a turning head on a milling machine in turbo post requires
!C      that the turning tool paths be created in a special workplane.
!C      This script provides that workplane.
!C
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: workplane: zx turning ")

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

Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave
DeActivateUndo
StdWorkplane
stat= SetInputFormat("n4","")

Start:!
Stat=SetEqualsValue(Angle)
Stat=SetInputFormat("n4=","")

Angle= GetValue("FACE ANGLE  0, 90, 180, 270, ",Answer$)
IF (ExitScript(Destination$)) THEN Leave

Center_point: E1=PickEntity("PICK CENTER POINT")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN First_point
T1= LastPickPara
Pick_return1= CurrPickReturn
Stat= EntityNameCheck(E1,Point1$)


Stat= GenerateVarName(WsTransformEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("WORKPLANE: ZX Workplane")
Stat=SetWorkplane
SELECT Pick_return1
CASE WsGeometryEnd
        P1= ParameterReturnPt(Point1$,T1,WsGeometryEnd)
CASE WsGeometryMid
        P1= ParameterReturnPt(Point1$,T1,WsGeometryMid)
CASE WsGeomCenter
        P1= ParameterReturnPt(Point1$,T1,WsGeomCenter)
END SELECT
V1= FreeParameter("Angle ",Angle)
Pz= PointXYZ(0,0,0)
Pt= PointPolar(Pz,1,V1,0)
P2= PtIncrXyz(P1,YPointValue(Pt),0.0,XPointValue(Pt))
P3= PtIncrXyz(P1,XPointValue(Pt),0.0,-YPointValue(Pt))
Trans1=ThreePtTrans(P1,P2,P3)
Stat=SetWorkplane(Trans1)
Stat= NameEntity(Trans1,Name$)
Stat= DeleteEntityList(P1,P2,P3,Pz,Pt)
RecordFunctionOff
CloseVarRecord

IF IsRulerOn THEN PlotAll

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