
! script name: vzplanes.d/parallelpt
! var_topic: define workplane parallel to existing workplane through point

!A
!A NAME:
!A
!A 	Parallel Workplane Through a Point	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows a workplane to be made parallel to an existing
!A 	workplane through a defined point.
!A
!B INSTRUCTIONS:
!B
!B 	PICK ENTITY FOR EXISTING WORKPLANE: Pick
!B 		an entity on the existing workplane.
!B
!B 	WORKPLANE ZERO ABS X,Y,Z: Enter the X,Y,Z
!B 		coordinates of the point to be used as the
!B 		reference point for making the new workplane.
!B 		NOTE: See XYZ INPUT OPTIONS.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: parallel workplane through a point ")

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

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

DeActivateUndo
stat= SetInputFormat("n4","")

Pick_entity:E1=PickEntity("PICK ENTITY FOR EXISTING WORKPLANE")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_entity
Stat= EntityNameCheck(E1,Element$)

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

Stat= GenerateVarName(WsTransformEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("WORKPLANE: Parallel thru point")
Stat=SetWorkplane(Element$)
Trans1= CurrentWorkplane
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
Trans2= ParallelPointTrans(Trans1,Pc)
Stat=SetWorkplane(Trans2)
Stat= NameEntity(Trans2,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
