
! script name: pkswept.d/pkvarcross
! solids: construct variable cross section sheet body

!A
!A NAME:
!A
!A 	Variable Contour Sweep
!A
!A DESCRIPTION:
!A
!A 	This script will make a variable cross section sheet.  At every point
!A 	of the drive contour, a cross section is created which is a linear blend
!A 	of the starting and ending cross sections.  The starting and ending
!A 	cross sections must be placed at the start and end points respectively
!A 	of the drive contour.
!A
!B INSTRUCTIONS:
!B
!B 	U PATCH WIDTH: Enter the width of the patch to be
!B 		used along the cross section contours.
!B
!B 	V PATCH WIDTH: Enter the width of the patch to be
!B 		used along the drive contour.
!B
!B 	PICK DRIVE CONTOUR: Pick the generating contour.
!B
!B 	PICK STARTING CROSS SECTION: Pick the constant cross section.
!B
!B 	PICK ENDING CROSS SECTION: Pick the constant cross section.
!B
!C NOTES:
!C
!C 	The starting and ending cross sections must have the same number of
!C 	elements.
!C
!C 	The patch widths need not match small radii. The surface will
!C 	automatically be created width a minimum number of patches on small
!C 	radii. Small splines however will require consideration in patch size.
!C
!C 	The optimum workplane for a variable cross section is the workplane of
!C 	the drive contour. Most other workplanes will give an equivalent
!C 	surface, but in some workplanes the surface may not be generated, or it
!C 	may give undesirable results.
!C
!C 	The drive contour must not ever become perpendicular to the workplane.
!C 	If this occurs the orientation of the cross section becomes confused.
!C
!C 	The U contours of the variable cross section surface are the cross
!C 	sections.  The V contours are the contours generated along the drive
!C 	contour.
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: variable cross section sheet ")

DIM Answer$[256]
DIM Destination$[256]

ActivateUndo
Patch_width=NamedVarVal("3D Default Patch",Ws3DSystemVars,0.5)
Stat= GLPlotOn

Uwidth=Patch_width
Vwidth=Patch_width
Blend_loop:!

Stat=SetInputFormat("n4=","")
Stat=SetEqualsValue(Uwidth)
Uwidth=GetValue("U PATCH WIDTH",Answer$)
IF ExitScript(Destination$) THEN Leave

Stat=SetEqualsValue(Vwidth)
Vwidth=GetValue("V PATCH WIDTH",Answer$)
IF ExitScript(Destination$) THEN Leave

Pick_loop: !
Stat=SetPickMask(WsPickNoSurf)
Contour=PickGroupEnt("PICK DRIVE CONTOUR ",0)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Contour) THEN Pick_loop
Stat=Highlight(Contour,WsPickPen,WsDirArrowOff)

Pick_cross1: Stat=SetPickMask(WsPickNoSurf)
Cross_section1=PickGroupEnt("PICK STARTING CROSS SECTION ",0)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Cross_section1) THEN Pick_cross1
Stat=Highlight(Cross_section1,WsPickPen,WsDirArrowOff)

Pick_cross2: Stat=SetPickMask(WsPickNoSurf)
Cross_section2=PickGroupEnt("PICK ENDING CROSS SECTION ",0)
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Cross_section2) THEN Pick_cross2
Stat=Highlight(Cross_section2,WsPickPen,WsDirArrowOff)

WPKClearErrorFlag
PlotOff
Surf=VarCrossSurface(Contour,Cross_section1,Cross_section2,Uwidth,Vwidth)
PlotOn
S1=WPKMakeBsurf(Surf)
Stat= DeleteEntity(Surf,WsTrue)

ActivateUndo
Stat= AdvanceUndoNumber("variable ent sweep")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck


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