
! script name: surfaces.d/entitysweep
! 3dtopic: surface created by sweeping one entity along another

!A
!A NAME:
!A
!A 	Sweep Entity Surface	
!A
!A DESCRIPTION:
!A
!A 	This script will make a constant cross section surface.  This surface
!A 	is created by sweeping a cross section entity along the drive entity,
!A 	maintaining the cross section normal to the drive entity.  The cross
!A 	section entity must be described at the start point of the drive
!A 	entity in 3D position.
!A
!B INSTRUCTIONS:
!B
!B 	U PATCH WIDTH: Enter the width of the patch to
!B 		be used along the cross section contour.
!B
!B 	V PATCH WIDTH: Enter the width of the patch to
!B 		be used along the drive contour.
!B
!B 	PICK DRIVE ENTITY: Pick the generating entity.
!B
!B 	PICK CROSS ENTITY: Pick the constant cross entity.
!B
!C NOTES:
!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 constant 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 entity 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 constant 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: sweep entity ")

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

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

Uwidth=Patch_width
Vwidth=Patch_width

ActivateUndo
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

Cont_count=1
Pick_loop: !
Stat=SetPickMask(WsPickNoSurf)
Drive_ent=PickEntity("PICK DRIVE ENTITY ")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Drive_ent) THEN Pick_loop
T1= LastPickPara
Dir1= (T1<= 0.5)*WsForward+ (T1> 0.5)*WsReverse


Pick_cross: Stat=SetPickMask(WsPickNoSurf)
Cross_ent=PickEntity("PICK CROSS SECTION ENTITY")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidGeometry(Cross_ent) THEN Pick_cross
T2= LastPickPara
Dir2= (T2<= 0.5)*WsForward+ (T2> 0.5)*WsReverse


Surf=ConstCrossSurface(Drive_ent,Cross_ent,Uwidth,Vwidth,Dir1,Dir2)

ActivateUndo
Stat= AdvanceUndoNumber("bicubic surface")
Stat= AddItemToUndo(WsUBCreateMode,Surf)
GOTO Blend_loop

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