
! script name: vpkswept.d/vpksweepent
! var_solids: construct body by sweeping an entity along a line

!A
!A NAME:
!A
!A 	Sweep: Translate Entity  VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script will sweep an entity along a line. The resulting 
!A 	parasolids body will be a sheet body.
!A
!B~ image location - images/pktranslatecontour.gif
!B
!B INSTRUCTIONS:
!B
!B 	PICK ENTITY 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 entity")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM Element$[256]
DIM Xshift_var$[256]
DIM Yshift_var$[256]
DIM Zshift_var$[256]

ActivateUndo
Var_object= CheckVarObject
IF (ExitScript(Destination$)) THEN Leave

Stat= GLPlotOn
Pick_entity:!
E1=PickEntity("PICK ENTITY TO BE SWEPT")
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(E1) THEN Pick_entity
Stat= EntityNameCheck(E1,Element$)

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

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

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


WPKClearErrorFlag
Stat= GenerateVarName("Body",Name$)
RecordFunctionOn
Stat= RecordDescr("SOLID: Translate entity")
IF No_xshift_var THEN
        V1= FreeParameter("X shift",Xshift)
ELSE
        V1= FreeParameter("X shift",Xshift_var$)
END IF
IF No_yshift_var THEN
        V2= FreeParameter("Y shift",Yshift)
ELSE
        V2= FreeParameter("Y shift",Yshift_var$)
END IF
IF No_zshift_var THEN
        V3= FreeParameter("Z shift",Zshift)
ELSE
        V3= FreeParameter("Z shift",Zshift_var$)
END IF
Ps= PointXYZ(0,0,0)
Pe= PointXYZ(V1,V2,V3)
L1=LineTwoPoints(Ps,Pe,WsTRIMMED)
Pkbody=WPKSweepContour(Element$,L1,WsFalse)
Stat= WPKNameBody(Pkbody,Name$)
Stat= WPKSetBodyParent(Pkbody)
Stat= DeleteEntityList(Ps,Pe,L1)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

Stat= WPKSolidRecordOn(Curr_record)
ActivateUndo
Stat= AdvanceUndoNumber("translate entity")
Stat= AddItemToUndo(WsUBPKSessionMark)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
WPKErrorCheck
GOTO Pick_entity



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