
! script name: pksurfaces.d/arcblend
! solids: construct sheet body of equal arc length sections

!A
!A NAME:
!A
!A 	Sheet Body: Spline Equal Arc Length Blend 
!A
!A DESCRIPTION:
!A
!A 	This script will make a cubic surface blending the sections by
!A	points laid out at equal arclengths along the sections.
!A
!B INSTRUCTIONS:
!B
!B 	PATCH WIDTH: Enter the width of the patch to be used.
!B
!B 	PICK CONTOUR # , Proceed: Pick the contours in order.  The actual point
!B 		picked on the contour determines the direction of the surface
!B 		created.
!B
!# see also - htdocs/help.d/parasolids.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: arc length blend ")

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

ActivateUndo
Active_workplane=0
Work=CurrentWorkplane
IF ValidGeometry(Work) THEN Active_workplane=1

Patch_width=NamedVarVal("3D Default Patch",Ws3DSystemVars,0.5)
Highlight_color= 2
Stat= SetDefaults(WsSelectedEntPen,Highlight_color)

Stat= GLPlotOn
Blend_loop:!
StdWorkplane

Group=CreateGroup("TEMP")

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

Cont_count=1
Pick_loop: !
Stat=SetInputFormat("a1",",P,")
Stat=SetPickMask(WsPickNoSurf)
Contour=PickGroupEnt("PICK CONTOUR #"&VAL$(Cont_count)&", Proceed ",0,Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$="P" THEN Blend_ents
IF NOT ValidGeometry(Contour) THEN Pick_loop

Stat=SetPickMask(WsPickAll)
Stat=AddToGroup(Group,Contour)
Stat= SetSelectedFlag(Contour,WsTrue)
Cont_count=Cont_count+1
GOTO Pick_loop

Blend_ents: !
UnselectAll
Grp_count=GroupCount(Group)
WPKClearErrorFlag
Pkbody=WPKEqualArcSurf(Group,Patch_width)
Stat=DeleteEntity(Group)

ActivateUndo
Stat= AdvanceUndoNumber("blend surface")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck

GOTO Blend_loop

Leave:!
UnselectAll
Stat=DeleteEntity(Group)
Stat=SetPickMask(WsPickAll)
IF Active_workplane THEN
	Stat=SetWorkplane(Work)
ELSE
	StdWorkplane
END IF
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
