
! script name: 3dintersect.d/sparting
! 3dtopic: generates a parting line curve on a surface

!A
!A NAME:
!A
!A 	Intersect: Surface Parting Line
!A
!A DESCRIPTION:
!A
!A 	This script generates the parting line curve on a surface.  The parting
!A 	line curve is defined as the locus of points on a surface at which the
!A 	tangent plane to the surface makes the given angle with the Z axis.
!A
!B INSTRUCTIONS:
!B
!B 	TAPER ANGLE: Input taper angle.
!B 		For example: A 2 degree draft would require a 2 degree angle.
!B
!B 	PICK SURFACE: Pick the surface.
!B
!C NOTES:
!C
!C 	The surface must have its normal vector oriented properly.
!C


Stat=ChangeLabelStr("ScriptNameStatus","Function: surface parting line curve ")

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

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

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

Angle=InputAngle("TAPER ANGLE")
IF ExitScript(Destination$) THEN Leave

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

Stat=SetPickMask(WsPickGeometry)
Path_group=SurfPartingCurve(Surface,Angle,Tol)

ActivateUndo
Stat= AdvanceUndoNumber("parting curve")
Stat= AddGroupToUndo(WsUBCreateMode,Path_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
