
! script name: vzplanes.d/xzplane
! var_topic: define XZ workplane

!A
!A NAME:
!A
!A 	XZ Plane	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows a workplane to be defined for the XZ plane.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ORIGIN POINT: Pick the point that will be used for the
!B 		reference point of the XZ plane being defined.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: xz plane ")

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

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

DeActivateUndo
StdWorkplane
Stat=SetInputFormat("n4","")

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

Stat= GenerateVarName(WsTransformEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("WORKPLANE: XZ Workplane")
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=AngleTransform(Pc,90,0,0)
Stat=SetWorkplane(Trans1)
Stat= NameEntity(Trans1,Name$)
Stat=DeleteEntity(Pc)
RecordFunctionOff
CloseVarRecord

Stat= PlotEntity(Center$)
IF IsRulerOn THEN PlotAll

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

