
! script name: vcopy.d/2dinccopycont
! var_topic: 2D copy contour by incremental moves

!A
!A NAME:
!A
!A 	2D Incremental Copy Picked Group  VARIATIONAL
!A
!A DESCRIPTION:
!A
!A 	This script allows a contour to be copied.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR TO BE COPIED: Pick contour to be copied.
!B
!B 	X,Y INCREMENT: Enter the value in X,Y to shift entities.
!B
!B 	NUMBER OF TIMES: Enter the number of times the copy process
!B 		should be repeated.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: 2d incremental copy contour ")

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

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

Highlight_color= 3

Start: !
ActivateUndo
Contour=PickGroupEnt("PICK CONTOUR TO BE COPIED")
IF ExitScript(Destination$) THEN Leave
IF NOT ValidDependency(Contour) THEN Start
Stat= EntityNameCheck(Contour,Contour$)
Stat=Highlight(Contour,Highlight_color,WsDirArrowOff)
IF NOT ValidGeometry(Contour) THEN
        GOTO Start
ELSE
        IF NOT GroupCount(Contour) THEN Start
END IF


stat= SetInputFormat("n4=","")
stat= SetEqualsValue(Xmove)
Xmove=GetValue("X INCREMENT ")
IF ExitScript(Destination$) THEN Leave
No_x_var= LastVariableInput(X_var$)

stat= SetInputFormat("n4=","")
stat= SetEqualsValue(Ymove)
Ymove=GetValue("Y INCREMENT ")
IF ExitScript(Destination$) THEN Leave
No_y_var= LastVariableInput(Y_var$)


Zmove= 0

Stat=SetInputFormat("n0=","")
Stat=SetEqualsValue(1)
Number=GetValue("NUMBER OF TIMES",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Number=0 THEN Start
No_times_var= LastVariableInput(Ntimes_var$)


Stat= GenerateVarName(WsGroupEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("COPY: 2d copy contour")
Stat= SetRecDelLastExec
Stat= NullReference(Contour$)
IF No_x_var THEN
	V1= FreeParameter("Xmove",Xmove)
        IF No_y_var THEN
		V2= FreeParameter("Ymove",Ymove)
                Move_vector= PointXYZ(V1,V2,0.0)
        ELSE
                Move_vector= PointXYZ(V1,Y_var$,0.0)
        END IF
ELSE
        IF No_y_var THEN
		V2= FreeParameter("Ymove",Ymove)
                Move_vector= PointXYZ(X_var$,V2,0.0)
        ELSE
                Move_vector= PointXYZ(X_var$,Y_var$,0.0)
        END IF
END IF


IF Number>1 THEN
        IF No_times_var THEN
		V3= FreeParameter("Number",Number)
                G1= VectorCopyGroup(Contour$,Move_vector,V3)
        ELSE
                G1= VectorCopyGroup(Contour$,Move_vector,Ntimes_var$)
        END IF
ELSE
        G1= VectorCopyGroup(Contour$,Move_vector)
END IF
Stat= AutoNameGroup(G1,Name$)
Stat= SetNoPathFlag(G1,WsTrue)
Stat= DeleteEntity(Move_vector)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

ActivateUndo
Stat= AdvanceUndoNumber("2d copy")
Stat= AddGroupToUndo(WsUBCreateMode,G1,1,WsTrue)
Stat= AddItemToUndo(WsUBCreateMode,Curr_record)

GOTO Start

Leave: !
ActivateUndo
stat= SetInputFormat("n4","")


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

