
! script name: colors.d/colorenttype
! topic: assign color to elements in box by Entity Type

!A
!A NAME:
!A
!A 	Color in Box by Entity Type
!A
!A DESCRIPTION:
!A
!A 	This script allows a box to be made around the elements to be
!A 	colored.  If part of an element is inside the view box, the
!A 	entire element is colored.
!A
!B INSTRUCTIONS:
!B
!B 	SELECT VIEW FOR SELECTION BOX: Pick the view that elements will be
!B 		colored in.
!B
!B 	PICK FIRST CORNER OF PICK ZONE: Pick a corner of the box.
!B
!B 	PICK SECOND CORNER OF PICK ZONE: Pick the other corner of the view box.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: color by entity type ")

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


ActivateUndo
Start:!

E1=PickEntity("PICK ELEMENT TO DETERMINE ENTITY TYPE")
IF (ExitScript(Destination$)) THEN Leave
Etype= EntityType(E1)

Pen_color= CurrentColor
RaiseColorBox

Group_loop:!
Group=CreateGroup("TEMPGROUP")

Vnum= LastPickView
Stat=PickBox(Group,Vnum,0)
IF (ExitScript(Destination$)) THEN Leave

Group1= GrpByEntType(Group,Etype)

ActivateUndo
Stat= AdvanceUndoNumber("color entity type")
Stat= AddGroupToUndo(WsUBModifyMode,Group1,0,WsFalse)

Stat=SetColor(Group1)
Stat= PlotEntity(Group1)
Stat=DeleteEntity(Group)
Stat=DeleteEntity(Group1)

GOTO Group_loop

Leave:!
LowerColorBox
Stat=DeleteEntity(Group)
Stat=DeleteEntity(Group1)
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END


