
! script name: pksolids.d/pktaperbodytwo
! solids: apply taper to a both sides of a body

!A
!A NAME:
!A
!A 	Two Sided Taper Body
!A
!A DESCRIPTION:
!A
!A 	This script will apply taper to a body on both sides of a
!A	supplied parting line body (usually a sheet body).
!A
!A
!A~ image location - images/pktaperbodytwo.gif
!B INSTRUCTIONS:
!B
!B	MITER AT PARTING  Yes or No: If yes is specified the tapered faces
!B			will match at the parting line even if it means 
!B			increasing the taper angle on one side to force
!B			the match.
!B
!B	TAPER ANGLE ABOVE: Taper angle on the part of the body above the
!B			   parting line.
!B
!B	TAPER ANGLE BELOW: Taper angle on the part of the body below the
!B			   parting line.
!B
!B	ABOVE REFERENCE EDGE GROUP: Reference edges for upper body.
!B                      The edge group must form single connected curve
!B                      which lies above the parting body. The curve cannot
!B                      cross the parting body.
!B
!B	BELOW REFERENCE EDGE GROUP: Reference edges for lower body.
!B                      The edge group must form single connected curve
!B                      which lies below the parting body. The curve cannot
!B                      cross or intersect the parting body.
!B
!B	SELECT PARTING BODY: Select the parting body.
!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: two sided 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("a1=",",Y,N,")
Stat=SetEqualsValue(0,"Y")
Stat=GetValue("MITER AT PARTING  Yes or No  ",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$= "Y" THEN
	Miter= WsTrue
ELSE
	Miter= WsFalse
END IF

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

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

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

Pkbody= WPKParentBody(E1)
Pkabove_grp= WPKContainingGroup(E1,1)
IF NOT WPKIsEntity(Pkabove_grp) THEN Above_reference

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

Pkbelow_grp= WPKContainingGroup(E1,1)
IF NOT WPKIsEntity(Pkbelow_grp) THEN Below_reference


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,Pkabove_grp,Pkbelow_grp,Angle_above,Angle_below,Method,Miter,Merge_faces,Corner_type)

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

Leave:!
PlotOn
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)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
