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

!A
!A NAME:
!A
!A 	Intersect: Part Parting Line
!A
!A DESCRIPTION:
!A
!A 	This script generates the parting line curve on a part.  The parting
!A 	line curve is defined as the locus of points on a part at which the
!A 	tangent plane to the part 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 GROUP: Select a group of surfaces.
!B
!C NOTES:
!C
!C 	The surface group must have its normal vectors oriented consistently.
!C

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

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

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

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("n4","")
Part_group=PickGroupEnt("PICK SURFACE GROUP ",WsSurfaceGroup)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Part_group) THEN Intersect2

Stat=Highlight(Part_group,WsPickPen,WsDirArrowOff)
Stat=SetPickMask(WsPickGeometry)

path_group=PartPartingCurve(Part_group,Angle,Tol)

ActivateUndo
Stat= AdvanceUndoNumber("parting 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
