
! script name: pkswept.d/pksweepcontour
! solids: construct body by sweeping a contour along a line

!A
!A NAME:
!A
!A 	Sweep: Translate Contour
!A
!A DESCRIPTION:
!A
!A 	This script will sweep a contour along a line. The resulting 
!A 	parasolids body will be either a sheet body or a solid body
!A 	depending on if the contour is open or closed.
!A
!B~ image location - images/pktranslatecontour.gif
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR TO BE SWEPT: Select the contour to be swept.
!B 		It must be a synergy contour.
!B
!B 	X SHIFT: Amount to be swept in the x direction.
!B
!B 	Y SHIFT: Amount to be swept in the y direction.
!B
!B 	Z SHIFT: Amount to be swept in the z direction.
!B
!# see also - htdocs/help.d/parasolids.htm

Stat=ChangeLabelStr("ScriptNameStatus","Function: sweep contour")

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

ActivateUndo

Stat= GLPlotOn
Pick_contour:!
Stat=SetInputFormat("a1",",E,")
Contour=PickGroupEnt("PICK CONTOUR  Edge group",0,Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$= "E" THEN
	Solid_body= WsFalse

	E1=WPKPickEntity("PICK EDGE GROUP",WsPKPickEdges)
	IF (ExitScript(Destination$)) THEN Leave
	IF NOT WPKIsEntity(E1) THEN Pick_contour

	Pkgroup= WPKContainingGroup(E1,1)
	IF NOT WPKIsEntity(Pkgroup) THEN Pick_contour

	Contour= Pkgroup
ELSE
	Closed= IsContClosed(Contour)
	Solid_body= WsFalse
	IF Closed THEN
		Stat=SetInputFormat("a1=",",1,2,")
		Stat=SetEqualsValue(0,"Solid")
		Stat=GetValue("BODY TYPE:  ( 1 ) solid  ( 2 ) sheet ",Answer$)
		IF ExitScript(Destination$) THEN Leave
		IF Answer$= "1" THEN Solid_body= WsTrue
	END IF
END IF

Stat=SetInputFormat("n4=","")
Stat=SetDepthEquals(Xshift)
Xshift=InputDepth("X SHIFT")
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetDepthEquals(Yshift)
Yshift=InputDepth("Y SHIFT")
IF ExitScript(Destination$) THEN Leave

Stat=SetInputFormat("n4=","")
Stat=SetDepthEquals(Zshift)
Zshift=InputDepth("Z SHIFT")
IF ExitScript(Destination$) THEN Leave

Ps= PointXYZ(0,0,0)
Pe= PointXYZ(Xshift,Yshift,Zshift)
L1=LineTwoPoints(Ps,Pe,WsTRIMMED)

WPKClearErrorFlag
Pkbody=WPKSweepContour(Contour,L1,Solid_body)

Stat=SetLastPoint(Pe)
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
Stat=DeleteEntity(L1)
ActivateUndo
Stat= AdvanceUndoNumber("swept contour")
Stat= AddItemToUndo(WsUBPKSessionMark)
WPKErrorCheck
GOTO Pick_contour

Leave:!
Stat=DeleteEntity(Ps)
Stat=DeleteEntity(Pe)
Stat=DeleteEntity(L1)
IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
