/*******************************************************************
Function to set Material, 2D behavior, and thickness for Bodies from Excel
The Excel file contains data as 4 columns:
NS_Name Mat_Name Behavior Thickness
Line-1 is header
Line-2 to "n" contains valid data
Behavior options are: Axisymmetric, Plane Stress and Plane Strain
Thickness input is valid only for Plain Stress
Assumptions:
1. Model is 2D
2. The materials are already defined in Engineering Data
3. There are no empty cells between two rows of data in Excel
4. The Excel file contains valid NamedSelections of the surface bodies
The script is developed/tested for Mechanical in WB 13.0
**********************************************************************/
// Ask the user to choose the excel file
var dlg =
DS.Script.AnsObjectFactory.CreateDispatchObject(DS.Script.GenWBProgId("WBControls.WBF
ileDialog"));
dlg.DefaultFile = "InputData.xlsx";
dlg.DefaultDirectory = "./";
dlg.Filter = "Excel files (*.xls; *.xlsx)|*.xls;*.xlsx";
dlg.FilterIndex = 0;
dlg.ForOpen = true;
dlg.Popup(0); // Popup the file browser
var ExcelFilename = dlg.SelectedFile;
var oScript = DS.Script;
var BodyGName = new Array();
var BodyMat = new Array();
var BodyType = new Array();
var BodyThick = new Array(); // Valid if BodyType == Plane Stress
// Read the Excel file and store all data in Arrays
if (ExcelFilename != "") {
var Excel = new ActiveXObject("Excel.Application");
Excel.Workbooks.Open(ExcelFilename);