
! script name: v3dinter.d/sparting
! var_topic: generates a parting line curve on a surface

!A
!A NAME:
!A
!A 	Intersect: Surface Parting Line		VARIATIONAL
!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]
DIM Surface$[256]
DIM Name$[256]
DIM Taper_var$[256]

Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave
Tol=NamedVarVal("3D Intersect Tol",Ws3DSystemVars,0.005)

ActivateUndo
Start:!
Taper=InputAngle("TAPER ANGLE")
IF ExitScript(Destination$) THEN Leave
No_taper_var= LastVariableInput(Taper_var$)

Pick_surf1:!
Stat=SetPickMask(WsPickSurfOnly)
Stat=SetInputFormat("n0","")
Surface=PickEntity("PICK SURFACE ",Answer$)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Surface) THEN Pick_surf1
Stat= EntityNameCheck(Surface,Surface$)

Stat=SetPickMask(WsPickGeometry)

Stat= GenerateVarName(WsGroupEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("PARTING LINE: Surface")
Stat= SetRecDelLastExec
IF No_taper_var THEN
        V1= FreeParameter("Taper angle",Taper)
ELSE
        V1= FreeParameter("Taper angle",Taper_var$)
END IF
V2= FreeParameter("Tolerance",Tol)
Stat= Set3dInterOffset(0.0)
G1=SurfPartingCurve(Surface$,V1,V2)
Stat= AutoNameGroup(G1,Name$)
Stat= SetNoPathFlag(G1,WsTrue)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(G1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("parting line curve")
	Stat= AddGroupToUndo(WsUBCreateMode,G1,1,WsTrue)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF
GOTO Pick_surf1

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