
! script name: tools.d/toolinbox
! topic: assign tool to elements in box

!A
!A NAME:
!A
!A 	Tool In Box
!A
!A DESCRIPTION:
!A
!A 	This script allows a box to be made around the elements to be
!A 	associated.  If part of an element is inside the view box, the
!A 	entire element is associated.
!A
!B INSTRUCTIONS:
!B
!B	CHOOSE TOOL TO ASSOCIATE : Pick tool to use in the association.
!B
!B 	SELECT VIEW FOR SELECTION BOX: Pick the view that elements will be
!B 		associated 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
!B OPTIONS:
!B
!B 	The tool selection box will automatically appear to allow a tool to
!B 	be selected.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: tool in box ")

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

DeActivateUndo
Tool_loop:!
Stat=RemoveDupTools
No_box=ToolSelectBox("TOOLS","selected tool")
IF No_box THEN Leave

Stat= SetInputFormat("a99","")
Stat= GetValue("CHOOSE TOOL TO ASSOCIATE",Answer$)
IF ExitScript(Destination$) OR Answer$="CANCEL" THEN Leave

Tool= FindUserData(Answer$,WsToolData)
IF NOT ValidGeometry(Tool) THEN Tool_loop

LowerSelectBox

Ploop:!
Group=CreateGroup("TEMPGROUP")

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

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

Stat=Highlight(Group,WsPickPen,WsDirArrowOff)
Stat=AssociateTool(Group,Tool)
Stat=DeleteEntity(Group)

GOTO Ploop

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


