
! script name: vcopy.d/layercopycont
! var_topic: layer copy contour by incremental moves

!A
!A NAME:
!A
!A 	Layer Copy Contour
!A
!A DESCRIPTION:
!A
!A 	This script allows a contour to be copied to a layer.
!A
!B INSTRUCTIONS:
!B
!B 	PICK CONTOUR TO BE COPIED: Pick the contour to be copied.
!B
!B 	LAYER NUMBER: Enter the value for the layer where the copy is placed.
!B
!# see also - points.d/xyzinput.hlp

stat=ChangeLabelStr("ScriptNameStatus","Function: layer copy contour ")
DIM Answer$[256]
DIM Destination$[256]
DIM Contour$[256]
DIM Name$[256]
DIM Layer_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","")
Layer=InputLayer("LAYER NUMBER ")
IF ExitScript(Destination$) THEN Leave
No_layer_var= LastVariableInput(Layer_var$)

Stat= GenerateVarName(WsGroupEnt,Name$)
RecordFunctionOn
Stat= RecordDescr("COPY: Layer copy contour")
Stat= SetRecDelLastExec
Stat= NullReference(Contour$)
G1= CopyGroup(Contour$)
IF No_layer_var THEN
	V1= FreeParameter("Layer",Layer)
	Stat= SetLayer(G1,V1)
ELSE
	Stat= SetLayer(G1,Layer_var$)
END IF
Stat= AutoNameGroup(G1,Name$)
Stat= SetNoPathFlag(G1,WsTrue)
RecordFunctionOff
Curr_record= CurrentVarRecord
CloseVarRecord

ActivateUndo
Stat= AdvanceUndoNumber("layer 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



