
! script name: pksurfaces.d/wrappedloft
! solids: construct a lofted body through a series of wrapped profiles

!A
!A NAME:
!A
!A 	Wrapped Lofted Body
!A
!A DESCRIPTION:
!A
!A	This script will make a lofted body through a series of
!A	wrapped contours having the same number of elements.
!A
!A
!B INSTRUCTIONS:
!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 surface is created by blending the sections in order, element by
!C 	element.  The first element of section 1 to the first element of
!C 	section 2, the second element of section 1 to the second element of
!C 	section 2, and so forth.
!C		
!C	If there are only two closed contours they can be made into a solid
!C	body. Otherwise it will become a sheet body.
!C
!# see also - htdocs/help.d/parasolids.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: wrapped lofted body ")

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

ActivateUndo
Tol=NamedVarVal("3D Intersect Tol",Ws3DSystemVars,0.005)
Active_workplane=0
Work=CurrentWorkplane
IF ValidGeometry(Work) THEN Active_workplane=1

Stat= GLPlotOn
Blend_loop:!
Radius=InputRadius("RADIUS OF CYLINDER")
IF ExitScript(Destination$) THEN Leave

Astart=InputAngle("STARTING ANGLE")
IF ExitScript(Destination$) THEN Leave

Stat=SetAngleEquals(Taper)
Taper=InputAngle("TAPER ANGLE")
IF ExitScript(Destination$) THEN Leave

Group=CreateGroup("TEMP")
Cont_count=1
Solid_body= WsTrue
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=Highlight(Contour,WsPickPen,WsDirArrowOff)
Stat=AddToGroup(Group,Contour)
Cont_count=Cont_count+1
GOTO Pick_loop

Blend_ents: !
Grp_count=GroupCount(Group)
WPKClearErrorFlag
Pkbody=WPKWrapLoftBody(Group,Radius,Astart,Taper,Tol)
Stat=DeleteEntity(Group)

ActivateUndo
Stat= AdvanceUndoNumber("wrap lofted body")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck

GOTO Blend_loop

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