
! script name: 3dintersect.d/surfintpart
! 3dtopic: generate a group of paths of intersection of a surface and a part

!A
!A NAME:
!A
!A 	Intersect: Surface Intersect part.
!A
!A DESCRIPTION:
!A
!A 	This script will generate a group of paths of intersection of a surface
!A 	with a part  in 3d space.  There is a path generated for
!B 	each pair of intersecting surfaces.
!A
!B INSTRUCTIONS:
!B
!B 	PICK SURFACE : Pick  the surface  to be used for
!B 		the intersection.
!B
!B 	PICK SURFACE GROUP #2: Pick the other surface group to be used for the
!B 		intersection.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: surf intersect part ")

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

Stat=Setup3dCutter(WsNullTool,0.0,0.0,0.0,0.0,0.0)
Intersect2: StdWorkplane
Pick_loop:!

Stat=SetPickMask(WsPickSurfOnly)
Stat=SetInputFormat("n4","")
Surface=PickEntity("PICK SURFACE ")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Surface) THEN Pick_loop


Stat=SetPickMask(WsPickSurfOnly)
Stat=SetInputFormat("n4","")
Part_group=PickGroupEnt("PICK SURFACE GROUP ",WsSurfaceGroup)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Part_group) THEN Pick_loop

Stat=Highlight(Part_group,WsPickPen,WsDirArrowOff)

Stat=SetPickMask(WsPickGeometry)

Temp_group= CreateGroup("TEMP")

Stat= AddToGroup(Temp_group,Surface)
s1=1
s2=1
path_group=IntersectParts(Part_group,S1,Temp_group,S2,Tol)
Stat= DeleteEntity(Temp_group)

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

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