
! script name: colors.d/colorzlevel
! topic: assign color entities on the same z level.

!A
!A NAME:
!A
!A 	Color by Z level
!A
!A DESCRIPTION:
!A	
!A	This script will color all entities on the same z level
!A	relative to the xorkplane.
!A
!A
!B INSTRUCTIONS:
!B
!B
!B OPTIONS:
!B
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: color circles by zlevel")

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

ActivateUndo
Pen_color= CurrentColor
RaiseColorBox

Units= CurrentUnits
IF Units= WsMetric THEN
        Tol= .005
ELSE
        Tol= .0002
END IF


Z_level:!
stat= SetInputFormat("n4=","")
Stat= SetEqualsValue(Zlevel)
Stat=SetPickReturn(WsGeometryZ)
Zlevel=GetValue("Z LEVEL",Answer$)
IF (ExitScript(Destination$)) THEN Leave
Stat=SetPickReturn(WsGeometryEnd)

G1= GrpByZLevel(Zlevel,Tol,WsTrue)

ActivateUndo
Stat= AdvanceUndoNumber("color by z level")
Stat= AddGroupToUndo(WsUBModifyMode,G1,0,WsFalse)

Stat=SetColor(G1)
Stat= DeleteEntity(G1)

GOTO Z_level

Leave:!
LowerColorBox
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END
