
! script name: tools.d/toolentity
! topic: assign tool to single element

!A
!A NAME:
!A
!A 	Tool Entity
!A
!A DESCRIPTION:
!A
!A 	This script allows a single element to be associated to a tool.
!A
!B INSTRUCTIONS:
!B
!B	CHOOSE TOOL TO ASSOCIATE : Pick tool to use in the association.
!B
!B 	PICK ENTITY, New tool : Pick the element that will be associated.
!B		OR, choose a new tool
!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 entity ")

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

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:!
Stat= SetInputFormat("a1",",N,")
E1=PickEntity("PICK ENTITY, New tool",Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$= "N" THEN Tool_loop
Stat=AssociateTool(E1,Tool)

GOTO Ploop

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