
! script name: 3dintersect.d/sintersect
! 3dtopic: generate path of intersection of two surfaces

!A
!A NAME:
!A
!A 	Intersect: Surfaces
!A
!A DESCRIPTION:
!A
!A 	This script will generate all the paths of intersection for the two
!A 	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 intersection.
!B
!C NOTES:
!C
!C	The intersect curve 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]

ActivateUndo
Normal_len=NamedVarVal("3D Normal Length",Ws3DSystemVars,1.0)
Tol=NamedVarVal("3D Intersect Tol",Ws3DSystemVars,0.005)

Start:!
Normal_color=3
Direction_color=4

StdWorkplane

Stat=Setup3dCutter(WsNullTool,0.0,0.0,0.0,0.0,0.0)

Intersect2:StdWorkplane

Pick_loop:!

Stat=SetPickMask(WsPickSurfOnly)
Stat=SetInputFormat("n0","")
Surface1=PickEntity("PICK SURFACE #1",Answer$)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Surface1) THEN Pick_loop

Surface2=PickEntity("PICK SURFACE #2",Answer$)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Surface2) THEN Pick_loop

Stat=SetPickMask(WsPickGeometry)

s1=1
s2=1
path_group=IntersectSurfs(Surface1,S1,Surface2,S2,Tol)

ActivateUndo
Stat= AdvanceUndoNumber("intersect curve")
Stat= AddGroupToUndo(WsUBCreateMode,Path_group,1,WsTrue)
GOTO Intersect2

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