
! script name: 3dintersect.d/doessrfintprt
! 3DTOPIC: does a surface intersect a part

!A
!A NAME:
!A
!A 	Does a surface intersect a part.
!A
!A DESCRIPTION:
!A
!A 	This script will test if a surface intersects a part.
!A
!B INSTRUCTIONS:
!B
!B 	PICK SURFACE: Pick one of the two surfaces to be used for the
!B 		intersection. 
!B
!B 	PICK PART : Pick the  part to be used for the 
!B		intersection.
!B
!C  NOTES:
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: Does surf int part ")

DIM Destination$[256]
DIM Answer$[256]
DIM Surface_dir$[80]


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


Start:!
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 ",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Surface1) THEN Pick_loop


Pick_part:!
Stat= SetPickMask(WsPickSurfOnly)
Part2=PickGroupEnt("PICK PART ",0,Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidGeometry(Part2) THEN Pick_part

Stat= SetPickMask(WsPickGeometry)

Normal_sign1= 1
Normal_sign2= 1

Part1= CreateGroup("TEMP")
Stat= AddToGroup(Part1,Surface1)

Does_it= DoPartsIntersect(Part1,Normal_sign1,Part2,Normal_sign2,Tol)

Stat= DeleteEntity(Part1)

IF Does_it THEN

PRINT "The Surface and Part Do Intersect "

ELSE 

PRINT "The Surface and Part Do Not Intersect "

END IF


GOTO Intersect2


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