
! script name: pksolids.d/pktaperbodyup
! solids: apply taper to a body up to the parting body.

!A
!A NAME:
!A
!A 	Taper Body Up to Parting body.
!A
!A DESCRIPTION:
!A
!A 	This script applies taper to a body up to the parting body.
!A
!A
!A~ image location - images/pktaperbodyup.gif
!B INSTRUCTIONS:
!B
!B	TAPER ANGLE: Specify the taper angle.
!B
!B	PICK REFERENCE EDGE GROUP: Select the group of reference edges.
!B                      Reference edges should be grouped as a parasolid
!B                      group. The edge group must form single connected curve
!B                      which lies below the parting body. The curve cannot
!B                      cross the parting body.
!B
!B	SELECT PARTING BODY: Select the parting body (usually a sheet).
!B
!B NOTES:
!B
!B      The taper direction is determined by the positive z axis of
!B      the current workplane.
!B
!B	The parting body and the main body should intersect in a clean
!B	fashion. If the intersection between the body and the parting body
!B	is too complex this function will fail.
!B
!B      The following methods are available:
!B
!B              0,1) PK_taper_method_isocline_c (default)
!B              2)   PK_taper_method_curve_c    uses reference curves tangent.
!B              3)   PK_taper_method_surface_c  uses tapered face normal.
!B
!B	The default method will fail if the reference curves become steeper
!B	than the taper angle. In this case try another method. The method
!B	becomes a system variable once the script has been used.
!B
!B      The corner type specifies how geometry is to be constructed to
!B      fill the gaps between to adjacent tapered faces.
!B      The possible values for corner_type are
!B              0,1) PK_taper_corner_extend_c adjacent faces extended(default).
!B              2)   PK_taper_corner_plane_c plane face created filling gap
!B
!B	Corner type becomes a system variable once the script has been used.
!B
!# see also - htdocs/help.d/parasolids.htm


stat=ChangeLabelStr("ScriptNameStatus","Function: taper body ")

OPTION BASE 1
DIM Destination$[256]
DIM Answer$[256]

ActivateUndo

Stat= GLPlotOn
Start:!
Method=NamedVarVal("solid taper face method",WsPKSolidsVars,1.0)
Corner_type=NamedVarVal("solid taper corner type",WsPKSolidsVars,1.0)
Merge_faces=NamedVarVal("solid taper merge faces",WsPKSolidsVars,1.0)


Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Angle)
Angle=GetValue("TAPER ANGLE",Answer$)
IF ExitScript(Destination$) THEN Leave

Reference_loop:!
E1=WPKPickEntity("PICK REFERENCE EDGE GROUP",WsPKPickEdges)
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Start

Pkbody= WPKParentBody(E1)
Pkgroup= WPKContainingGroup(E1,1)
IF NOT WPKIsEntity(Pkgroup) THEN Start

Stat=SetInputFormat("n4","")
E1=WPKPickEntity("SELECT PARTING BODY")
IF (ExitScript(Destination$)) THEN Leave
IF NOT WPKIsEntity(E1) THEN Start
Pkparting= WPKParentBody(E1)

WPKClearErrorFlag
Stat= WPKTaperBody(Pkbody,Pkparting,0,Pkgroup,0.0,Angle,Method,WsFalse,Merge_faces,Corner_type)

ActivateUndo
Stat= AdvanceUndoNumber("taper body")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck

Leave:!
V1=CreateVariable("solid taper face method",WsPKSolidsVars,Method)
V2=CreateVariable("solid taper merge faces",WsPKSolidsVars,Merge_faces)
V3=CreateVariable("solid taper corner type",WsPKSolidsVars,Corner_type)
PlotOn
V1=CreateVariable("solid taper face method",WsPKSolidsVars,Method)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
