
! script name: v3dinter.d/int3planes
! var_topic: intersection point of three planes

!A
!A NAME:
!A
!A 	Intersect: 3 Plane	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script will find the intersection point between three Planes. 
!A
!B INSTRUCTIONS:
!B
!B 	PICK PLANE #1: Pick one of the three planes to be used for determining
!B 		the intersection point.
!B
!B 	PICK PLANE #2: Pick the second planes to be used for determining the
!B 		intersection point.
!B
!B 	PICK PLANE #3: Pick the third plane to be used for determining the
!B 		intersection point.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: intersect 3 planes ")

DIM Destination$[256]
DIM Answer$[256]
DIM Name1$[256]
DIM Name2$[256]
DIM Name3$[256]
DIM Name$[256]

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

ActivateUndo
Start:!

Pick_plane1:Stat=SetPickMask(WsPickSurfOnly)
Stat=SetInputFormat("n0","")
Plane1=PickEntity("PICK PLANE #1",Answer$)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Plane1) THEN Pick_plane1
Stat= EntityNameCheck(Plane1,Name1$)

Pick_plane2:Plane2=PickEntity("PICK PLANE #2",Answer$)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Plane2) THEN Pick_plane2
Stat= EntityNameCheck(Plane2,Name2$)

Pick_plane3:Plane3=PickEntity("PICK PLANE #3",Answer$)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Plane3) THEN Pick_plane3
Stat= EntityNameCheck(Plane3,Name3$)

Stat=SetPickMask(WsPickGeometry)


Stat= GenerateVarName(WsPointEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("POINT: Three Plane intersect")
Stat= SetRecDelLastExec
P1=Intersect3Planes(Name1$,Name2$,Name3$)
Stat= NameEntity(P1,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(P1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("intersect pt")
	Stat= AddItemToUndo(WsUBCreateMode,P1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Start

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