
! script name: surfaces.d/cubicblend
! 3dtopic: Sample - script for making a flat surface

!A
!A NAME:
!A
!A 	Flat Blend
!A
!A DESCRIPTION:
!A
!A 	NO HELP AVAILABLE AT THIS TIME
!A
!B INSTRUCTIONS:
!B
!B 	PATCH WIDTH: Enter the width of the patch to be used.
!B
!B 	PICK CONTOUR # :
!B
!C NOTE:
!C
!C 	This is an unsupported sample script.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: flat 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)

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=Highlight(Contour,WsPickPen,WsDirArrowOff)
stat= AddToGroup(Group,Contour)
Cont_count= Cont_count+1
GOTO Pick_loop

Blend_ents: !
Grp_count= GroupCount(Group)
Surf1= EqualElementSurf(WsFlatSurfEnt,Group,"BLEND",Patch_width)

ActivateUndo
Stat= AdvanceUndoNumber("flat surface")
Stat= AddItemToUndo(WsUBCreateMode,Surf1)
stat= DeleteEntity(Group)


GOTO Blend_loop

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