
! script name: drawings.d/ drwgviewscale
! topic: change the scale on a drawing view 

!A
!A NAME:
!A
!A 	View Scale
!A
!A DESCRIPTION:
!A
!A 	This script changes the scale on a drawing view
!A
!B INSTRUCTIONS:
!B
!B 	DRAWING NAME: Enter the name to be used for the drawing.
!B
!B      VIEW NUMBER, Pick: Either input the view to be scaled or select
!B                         P to pick the view. Warning picking may be difficult
!B                         especially on an iges drawing.
!B
!B 	VIEW SCALE: Enter the scale to be used for the view.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: view scale")

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



DeActivateUndo
Draw_loop:! 
StdWorkplane
Drawing= ActiveDrawing
IF ValidGeometry(Drawing) THEN View_loop

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

View_loop:!
Nviews= NumberDrawingViews(drawing)
IF Nviews=0 THEN Leave
A$= "1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 "
IF Nviews< 15 THEN
        N1= 3*(Nviews-1)+1
        A$= A$[1,N1]
END IF

Stat= SetInputFormat("n0a1",",P,")
View_num=GetValue("VIEW NUMBER, Pick  "&A$,Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$="P" THEN
	Stat= SetInputFormat("n4","")
	Pt=InputFreePoint("PICK WHICH VIEW")
	IF (ExitScript(Destination$)) THEN Leave
	IF NOT ValidGeometry(Pt) THEN View_loop

        View_num= FindClosestView(Drawing,Pt)
        Stat=DeleteEntity(Pt)
END IF
IF View_num< 1 THEN View_loop

Vscale= DrwgViewScale(Drawing,View_num)

stat= SetInputFormat("n4=","")
Stat= SetEqualsValue(Vscale)
Vscale= GetValue("VIEW SCALE ")
IF (ExitScript(Destination$)) THEN Leave

Stat= ChDrwgViewScale(Drawing,View_num,Vscale)

Stat= PlotDrawing(Drawing,1,WsFalse)
Stat= SetActiveDrawing(Drawing)

GOTO View_loop

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