
! script name: v3dinter.d/sintersect
! var_topic: generate path of intersection of two surfaces

!A
!A NAME:
!A
!A 	Intersect Surfaces	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script will generate all the paths of intersection 
!A 	of two surfaces.
!A
!B INSTRUCTIONS:
!B
!B 	PICK SURFACE #1: Pick one of the two surfaces to be used for the
!B 		intersection.
!B
!B 	PICK SURFACE #2: Pick the other surface to be used for the 
!B		intersection.
!B
!C NOTES:
!C
!C	The fillet surface is generated in such a way as to propagate
!C	in the same direction as the u-curves in the first surface picked.
!C	This is done to insure consistant generation for vdm.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: intersect surfaces ")

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

Tol=NamedVarVal("3D Intersect Tol",Ws3DSystemVars,0.005)

ActivateUndo
Start:!
Intersect2:!

Pick_surf1:Stat= SetPickMask(WsPickSurfOnly)
stat= SetInputFormat("n0","")
Surface1=PickEntity("PICK SURFACE #1",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Surface1) THEN Pick_surf1
Stat= EntityNameCheck(Surface1,Name1$)



Pick_surf2:Stat= SetPickMask(WsPickSurfOnly)
stat= SetInputFormat("n0","")
Surface2=PickEntity("PICK SURFACE #2",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Surface2) THEN Pick_surf2
Stat= EntityNameCheck(Surface2,Name2$)



s1=1
s2=1
Stat= GenerateVarName(WsGroupEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("CURVE: Intersect")
Stat= SetRecDelLastExec
stat= Set3dInterOffset(0.0)
V1= FreeParameter("Tolerance",Tol)
G1= IntersectSurfs(Name1$,S1,Name2$,S2,V1)
Stat= AutoNameGroup(G1,Name$)
Stat= SetNoPathFlag(G1,WsTrue)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(G1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("intersect surfs")
	Stat= AddGroupToUndo(WsUBCreateMode,G1,1,WsTrue)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Intersect2

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