
! script name: layers.d/layercontour
! topic: assign contours to layers

!A
!A NAME:
!A
!A 	Layer Contour
!A
!A DESCRIPTION:
!A
!A 	This script allows contours to be assigned to different layers.
!A
!B INSTRUCTIONS:
!B
!B 	LAYER NUMBER,   current layer= # : Enter the layer number that
!B 		will be assigned to the contour selected.
!B
!B 	PICK CONTOUR TO BE ASSIGNED LAYER # : Pick the contour that is
!B 		to be assigned to the layer selected.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: layer contour ")

DIM Destination$[256]
DIM Answer$[256]


ActivateUndo
Layer=CurrentLayer

Ask_layer=1
IF ARGC> 1 THEN Ask_layer=0

IF Ask_layer THEN
        Stat=SetInputFormat("n0=","")
        Stat= SetEqualsValue(Layer)
        Layer=InputLayer("LAYER NUMBER ")
        IF (ExitScript(Destination$)) THEN Leave
        Stat= SetCurrentLayer(Layer)
END IF

Ploop:!

Stat=SetInputFormat("n4a1",",N,")
IF (OSystemId=2) THEN ! NATIVE NT
E1=PickEntity("PICK CONTOUR, Name ",Answer$)
ELSE
E1=PickEntity("PICK CONTOUR, Name    LAYER   "&VAL$(Layer),Answer$)
END IF
IF (ExitScript(Destination$)) THEN Leave
IF Answer$= "N" THEN
	GOSUB Get_named_grp

	ActivateUndo
	Stat= AdvanceUndoNumber("layer contour")
	Stat= AddGroupToUndo(WsUBModifyMode,Group,2,WsTrue)

	Stat=LayerContour(Group,Layer)
	GOTO Ploop
END IF

Group= ParentGroup(E1)
ActivateUndo
Stat= AdvanceUndoNumber("layer contour")
Stat= AddGroupToUndo(WsUBModifyMode,Group,2,WsTrue)

Stat=LayerContour(E1)

GOTO Ploop


Get_named_grp:!
Stat=ListGrpNames("CONTOUR NAMES","selected group","",0)
IF Stat=1 THEN Leave
Stat=SetInputFormat("a99","")
Stat=GetValue("CONTOUR NAME",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Group=FindNamedGrp(Answer$)
IF NOT ValidGeometry(Group) THEN Get_named_grp
Stat=SetInputFormat("n4","")
LowerSelectBox
RETURN

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