
! script name: tools.d/toolcontour
! topic: assign tool to contour

!A
!A NAME:
!A
!A 	Tool Contour
!A
!A DESCRIPTION:
!A
!A 	This script allows a contour 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 CONTOUR, 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 contour ")

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=PickGroupEnt("PICK CONTOUR, New tool",0,Answer$)
IF ExitScript(Destination$) THEN Leave
IF Answer$= "N" THEN Tool_loop
Stat=Highlight(E1,WsPickPen,WsDirArrowOff)
Stat=AssociateTool(E1,Tool)
FOR J= 1 TO GroupCount(E1)
        E2= GroupElement(E1,J)
	Stat=AssociateTool(E2,Tool)
NEXT J

GOTO Ploop

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