
! script name: layers.d/layerdims
! topic: assign a composite dimension to layer

!A
!A NAME:
!A
!A 	Assign Layer to a Composite Dimension
!A
!A DESCRIPTION:
!A
!A 	This script allows a Composite Dimension to be assigned to a layer.
!A
!B INSTRUCTIONS:
!B
!B 	LAYER NUMBER,   current layer= # : Enter the layer number to
!B 		be assigned to the element selected.
!B
!B 	PICK DIMENSION TO BE ASSIGNED LAYER # : Pick the dimension to be
!B 		assigned to the layer.
!B

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

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:!

IF (OSystemId=2) THEN ! NATIVE NT
E1=PickEntity("PICK DIMENSION TO BE ASSIGNED LAYER ")
ELSE
E1=PickEntity("PICK DIMENSION TO BE ASSIGNED LAYER   "&VAL$(Layer))
END IF
IF (ExitScript(Destination$)) THEN Leave

IF NOT ValidGeometry(E1) THEN Ploop
E2= ParentDimEnt(E1)
IF NOT ValidGeometry(E2) THEN Ploop

ActivateUndo
Stat= AdvanceUndoNumber("layer dim")
Stat= AddDimToUndo(WsUBModifyMode,E2)

Stat=LayerDimension(E2)

GOTO Ploop

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