
! script name: v3dinter.d/intplanes
! var_topic: intersection line between two planes

!A
!A NAME:
!A
!A 	Intersect: 2 Planes 	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script will find the intersection line between two planes. 
!A
!B INSTRUCTIONS:
!B
!B 	PICK PLANE #1: Pick one of the planes to be used for the intersection.
!B
!B 	PICK PLANE #2: Pick the other plane to be used for the intersection.
!B

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

DIM Destination$[256]
DIM Answer$[256]
DIM Surface_dir$[80]
DIM Name1$[256]
DIM Name2$[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$)

Stat=SetPickMask(WsPickGeometry)

Stat= GenerateVarName(WsLineEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("LINE: Two Plane intersect")
Stat= SetRecDelLastExec
L1=IntersectPlanes(Name1$,Name2$)
Stat= NameEntity(L1,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(L1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("intersect line")
	Stat= AddItemToUndo(WsUBCreateMode,L1)
	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
