
! script name: vsolids.d/translation
! var_topic: generate solid of translation by moving a contour in XYZ

!A
!A NAME:
!A
!A 	Translation	VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script generates a solid of translation.  This solid is generated
!A 	by taking a contour and moving it in XYZ.  Every point of the contour
!A 	is moved simultaneously in the same direction.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR: Pick the contour to be used to generate a solid of
!B 		translation.
!B
!B 	X SHIFT: Enter the amount the contour is to be shifted in X relative
!B 		to the workplane.
!B
!B 	Y SHIFT: Enter the amount the contour is to be shifted in Y relative
!B 		to the workplane.
!B
!B 	Z SHIFT: Enter the amount the contour is to be shifted in Z relative
!B 		to the workplane.
!B
!C NOTES:
!C
!C 	The U contours of a translation are the contours and the V contours
!C 	are the lines.
!C
!C 	If the contour is in another workplane, the workplane must be
!C 	established before doing the translation.  The shift questions are
!C 	relative to that workplane.
!C

Stat=ChangeLabelStr("ScriptNameStatus","Function: translation ")

DIM Destination$[256]
DIM Answer$[256]
DIM Contour$[256]
DIM Name$[256]
DIM X_var$[256]
DIM Y_var$[256]
DIM Z_var$[256]
DEG

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

ActivateUndo
Start:!
stat= SetInputFormat("n4=","")
Stat=SetEqualsValue(Xmove)
Xmove=GetValue("X SHIFT ")
IF ExitScript(Destination$) THEN Leave
No_x_var= LastVariableInput(X_var$)

Stat=SetEqualsValue(Ymove)
Ymove=GetValue("Y SHIFT ")
IF ExitScript(Destination$) THEN Leave
No_y_var= LastVariableInput(Y_var$)

Stat=SetEqualsValue(Zmove)
Zmove=GetValue("Z SHIFT ")
IF ExitScript(Destination$) THEN Leave
No_z_var= LastVariableInput(Z_var$)

Pick_contour: !
stat= SetInputFormat("a1",",P,")
Stat= SetPickMask(WsPickNoSurf)
Contour=PickGroupEnt("PICK CONTOUR ",0)
IF (ExitScript(Destination$)) THEN Leave
IF NOT ValidDependency(Contour) THEN Pick_contour1
Stat= EntityNameCheck(Contour,Contour$)

Stat=Highlight(Contour,WsPickPen,WsDirArrowOff)

Stat= GenerateVarName(WsTranslationEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("TRANSLATION: Contour")
Stat= SetRecDelLastExec
IF No_x_var THEN
        V1= FreeParameter("Xmove",Xmove)
ELSE
        V1= FreeParameter("Xmove",X_var$)
END IF
IF No_y_var THEN
        V2= FreeParameter("Ymove",Ymove)
ELSE
        V2= FreeParameter("Ymove",Y_var$)
END IF
IF No_z_var THEN
        V3= FreeParameter("Zmove",Zmove)
ELSE
        V3= FreeParameter("Zmove",Z_var$)
END IF
T1=Translation(0,Contour$,V1,V2,V3)
Stat= NameEntity(T1,Name$)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord
IF NOT ValidGeometry(T1) THEN
        DelLastVarRecord
ELSE
	ActivateUndo
	Stat= AdvanceUndoNumber("translation")
	Stat= AddItemToUndo(WsUBCreateMode,T1)
	Stat= AddItemToUndo(WsUBCreateMode,Curr_record)
END IF

GOTO Pick_contour

Leave:!
Stat=DeleteEntity(Pt)
Stat= SetPickMask(WsPickAll)

IF NOT LEN(Destination$) THEN
	LOAD "typecontrol"
ELSE
	LOAD Destination$
END IF
END
