
! script name: subassembly.d/subassemblybox
! topic: set sub-assembly numbers on a group of elements in box

!A
!A NAME:
!A
!A 	Sub-Assembly in Box
!A
!A DESCRIPTION:
!A
!A 	This script allows a group of elements within a box to be assigned
!A 	a sub-assembly number.
!A
!B INSTRUCTIONS:
!B
!B 	SUB-ASSEMBLY NUMBER,   current subassembly= # : Enter the sub-assembly
!B		number to be assigned to the element selected.
!B
!B 	SELECT VIEW FOR SELECTION BOX: Pick the view that the elements are in.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: sub-assembly in box ")

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

SubAssembly=CurrSubAssembly

ActivateUndo
Start:!
Stat= SetInputFormat("n0a99","")
SubAssembly=InputSubAssembly("SUB-ASSEMBLY NUMBER, current subassembly= "&VAL$(SubAssembly),Answer$)
IF (ExitScript(Destination$)) THEN Leave
LowerSelectBox
stat= SetInputFormat("n4","")

Group_loop:!
Group=CreateGroup("TEMPGROUP")

Vnum=PickView("SELECT VIEW FOR SELECTION BOX")
IF (ExitScript(Destination$)) THEN Leave

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


ActivateUndo
Stat= AdvanceUndoNumber("set sub assembly")
Stat= AddGroupToUndo(WsUBModifyMode,Group,0,WsFalse)

Stat=SetSubAssembly(Group,SubAssembly)
Stat=DeleteEntity(Group)

GOTO Group_loop

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


