
! script name: surfaces.d/cubicarcblend
! 3dtopic: construct cubic surface using equal arc length

!A
!A NAME:
!A
!A 	Bicubic: Arc Length
!A
!A DESCRIPTION:
!A
!A 	This script will make a cubic surface.  The sections do not have to
!A 	have the same number of elements.  The longest section and the patch
!A 	width will determine the number of arcs used to create the cubic
!A 	surface.  Each section will be divided into the same number of patches,
!A 	but the patch width will vary depending on the length of the other
!A 	sections.  The order and position of the pick on the contours will
!A 	determine the direction.  The equal arc length cubic blend will not
!A 	necessarily give the best surface, the equal elements may be a better
!A 	selection in some instances, for example, when radii and the same 
!A 	number of elements on each section are involved.
!A
!B INSTRUCTIONS:
!B
!B 	PATCH WIDTH: Enter the width of the patch to be
!B 		maintained along the longest section.
!B
!B 	PICK CONTOUR # , Proceed: Pick the contours in order.
!B 		The actual point picked on the contour determines
!B 		the direction of the surface created.
!B
!C NOTES:
!C
!C 	The patch width must be smaller than any detail on the surface
!C 	represented.  For example, if one of the cross sections has a .5 inch
!C 	radius, the patch width should be no larger than 60% of the radius or
!C 	.3 inches, in this case.
!C 	This surface is not very good for representing a surface with a lot
!C 	of detail because of the small patch width required.
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: equal arc length cubic 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,")
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=ArcLenBlendSurf(WsCubicSurfEnt,Group,"BLEND",Patch_width)

ActivateUndo
Stat= AdvanceUndoNumber("bicubic surface")
Stat= AddItemToUndo(WsUBCreateMode,Surf1)

Stat=DeleteEntity(Group)
GOTO Blend_loop

Leave:!
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
