
! script name: tools.d/material
! topic: read data file for specified material

!A
!A NAME:
!A
!A 	SELECT MATERIAL
!A
!A DESCRIPTION:
!A
!A 	This script will read a data file for a specified material.
!A
!B INSTRUCTIONS:
!B
!B 	INPUT MATERIAL FILE NAME: The selection box with
!B 		the available list of MATERIALS will automatically
!B 		appear for a selection to be made.
!B

stat=ChangeLabelStr("ScriptNameStatus","Function: select material ")

DIM Destination$[256]
DIM Answer$[256]
DIM Name$[256]
DIM File_name$[256]
DIM Dir$[256]
DIM D_label$[256]
DIM Choice$[256]
DIM Namelist$[32000],Namelist2$[32000]
DIM Mask$[32]


DeActivateUndo
Start:!
Stat= NamedVarStr("material dir",WsSystemVars,"/usr/weber/util/tooldata/materials/",Dir$)
D_label$="MATERIALS DIRECTORY"
Choice$="MATERIALS SELECTED"
Mask$="*"
Stat=DirectoryNames(Dir$,Mask$,Namelist$)
Stat= AlphabeticalOrder(Namelist$,",",WsAscending,Namelist2$)
Stat=GeneralListBox(D_label$,Choice$,Namelist2$)


Stat=SetInputFormat("a99","")
Stat=GetValue("INPUT MATERIAL FILE NAME",Answer$)
IF (ExitScript(Destination$)) THEN Leave
IF Answer$="CANCEL" THEN Leave
File_name$= FileNameString(Dir$,Answer$)

Name$="MATERIAL"

Material=ReadUserData(WsMaterial,Name$,File_name$)
IF NOT ValidGeometry(Material) THEN Start

Leave:!
LowerSelectBox
IF (NOT LEN(Destination$)) THEN
	 LOAD "typecontrol"
ELSE
	 LOAD Destination$
END IF
END

