
! script name: 3dintersect.d/fouredges
! 3dtopic: generates a curve along all four surface edges

!A
!A NAME:
!A
!A 	Intersect: Surface Edges
!A
!A DESCRIPTION:
!A
!A 	This script generates a curve along all four surface edges.
!A
!B INSTRUCTIONS:
!B	
!B 	PICK SURFACE: Pick the surface.
!B

Stat=ChangeLabelStr("ScriptNameStatus","Function: four edges ")

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

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

ActivateUndo
Start:!
StdWorkplane
Stat=Setup3dCutter(WsNullTool,0.0,0.0,0.0,0.0,0.0)

Pick_loop:!

Intersect2:!

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


Edge_group=EdgeCurve(surface,tol)
Group=ExplodeTrimXYZ(Surface)

ActivateUndo
Stat= AdvanceUndoNumber("edge curves")
Stat= AddGroupToUndo(WsUBCreateMode,Group,1,WsTrue)

GOTO Intersect2

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