
! script name: drawings.d/ chdrawcolors
! topic: change associated drawing colors

!A
!A NAME:
!A
!A 	Change Associated Drawing Visible Colors
!A
!A DESCRIPTION:
!A
!A 	This script changes the visible colors associated to a drawing.
!A
!B INSTRUCTIONS:
!B
!B 	DRAWING NAME: Enter the drawing name.
!B
!B 	ASSOCIATED DRAWING COLORS, All: Enter the individual colors to be
!B 		visible on the drawing or enter "A" for all colors.
!B
!C NOTE:
!C	
!C	The colors specified here are for visibility purposes only.
!C	Only geometry with these colors will be drawn associated
!C	with the drawing.
!C

stat=ChangeLabelStr("ScriptNameStatus","Function: change assoc drawing colors ")

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


DeActivateUndo
Draw_loop:! 
StdWorkplane

Drawing= ActiveDrawing
IF ValidGeometry(Drawing) THEN Drawing_colors

Stat=UserSelectBox("DRAWINGS","selected drawing",WsDrawingSelect,WsDrawingSelect)
IF Stat=1 THEN Leave

Stat=SetInputFormat("a99","")
Stat=GetValue("DRAWING NAME",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$="CANCEL" THEN Leave
Name$=Answer$

LowerSelectBox
Drawing= FindNamedEntity(Name$)
IF ValidGeometry(Drawing) THEN
	StdWorkplane
	Stat= PlotDrawing(Drawing,1,WsTrue)
	Stat= SetActiveDrawing(Drawing)
ELSE
	StdWorkplane
	Stat= SetActiveDrawing
	GOTO Draw_loop
END IF
LowerSelectBox


Drawing_colors:Stat=SetInputFormat("a99",",A,N,",WsFalse)
Stat=GetValue("ASSOCIATED DRAWING COLORS, All ,",Colors$)
IF (ExitScript(Destination$)) THEN Leave
IF Colors$="CANCEL" THEN Leave
IF Colors$="A" OR Colors$="a" THEN Colors$=""
IF Colors$="All" OR Colors$="all" THEN Colors$=""
IF LEN(Colors$) THEN Colors$= ","&Colors$&","


Stat= SetDrawingColors(Drawing,Colors$)
Stat= PlotDrawing(Drawing,1,WsTrue)
Stat= SetActiveDrawing(Drawing)

GOTO Leave

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