
! script name: vcopy.d/zcopycont
! var_topic: z copy contour by incremental moves

!A
!A NAME:
!A
!A 	Z Copy contour
!A
!A DESCRIPTION:
!A
!A 	This script allows a contour to be copied.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR TO BE COPIED: Pick the contour to be copied.
!B
!B 	Z INCREMENT: Value in Z 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: z copy contour ")
DIM Answer$[256]
DIM Destination$[256]
DIM Contour$[256]
DIM Name$[256]
DIM X_var$[256]
DIM Y_var$[256]
DIM Z_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

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

Xmove= 0
Ymove= 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: Z copy contour")
Stat= SetRecDelLastExec
IF No_z_var THEN
	V1= FreeParameter("Zmove",Zmove)
        Move_vector= PointXYZ(Xmove,Ymove,V1)
ELSE
        Move_vector= PointXYZ(Xmove,Ymove,Z_var$)
END IF
IF Number>1 THEN
        IF No_times_var THEN
		V2= FreeParameter("Number",Number)
                G1= VectorCopyGroup(Contour$,Move_vector,V2)
        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

Stat= AdvanceUndoNumber("z copy contour")
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



