How can a user solve a Workbench / DesignSpace DSDB from a command line batch file on Unix ?


A Zip file containing the following script files is attached to this solution sol382668.zip


Batch.sh : a shell script that has to be run with an argument : the path to a folder where lie the DSDB files.

Launch.js : the jscript file where lie all the functions to open, clean, solve and save the DSDB files.

Launch.js must be in the same folder as batch.sh but those two files are not forced to be in the dsdb folder.

You do not need to provode for all the dsdb files names : the script automatically solves _ALL_ the dsdb files in the specified folder.






Batch.sh
--------------------------------------- Cut Here ---------------------------------------------
#!/bin/sh

if [ $# = 0 ]
then
echo "Error : You have to specify the path to the folder where the .DSDB files lie"
echo
exit
fi

pwd > repertoire
rep_courant=`cat repertoire`
rm -f repertoire

echo Looking for DSDB files in $1

dossier=$1
cd $dossier

for fichier in *.dsdb
do
chemin="$dossier/$fichier"
echo "$dossier/$fichier" > tmp
sed s/'/'/'/'/g tmp > tmp2
expr=`cat tmp2`
rm -f tmp tmp2

sed s/XXXXX/$expr/g $rep_courant/launch.js > $rep_courant/tmp_launch.js
echo
echo Resolution of $fichier
/ansys_inc/v90/aisol/startpage -script $rep_courant/tmp_launch.js
echo
rm $rep_courant/tmp_launch.js
done


--------------------------------------- Cut Here ---------------------------------------------

Launch.js
--------------------------------------- Cut Here ---------------------------------------------

DS = WB.AppletList.Applet("DSApplet").App;
PM = WB.AppletList.Applet("PMApplet").App.PartManager;
script = DS.Script;

fileName = "XXXXX";

DS.FileOpen(fileName);

CleanAllBranches();

SolveAllBranches();

script.doFileSave(fileName);

WB.FileExit();

function CleanAllBranches()
{
DS.script.WBScript.Silent = true;
var projectObj= DS.Tree.Projects(1); // Always 1 project per DSDB
DS.Tree.CleanDSDB(projectObj.ID);
}

function SolveAllBranches()
{
DS.script.WBScript.Silent = true;
var projectObj = DS.Tree.Projects(1); // Always 1 project per DSDB

for (var modelCount = 1; modelCount <= projectObj.Models.Count; modelCount++) // Loop through the models if more than 1

{


for (var environCount = 1; environCount <= projectObj.Models(modelCount).Environments.Count; environCount++) // Loop thru the Environments if more than 1
{

var envSet = projectObj.Models(modelCount).Environments(environCount);

var ansSet = projectObj.Models(modelCount).Environments(environCount).AnswerSet;




ansSet.SolveBranch(); // Solve each Solution object



}

}

}

--------------------------------------- Cut Here ---------------------------------------------





Show Form
No comments yet. Be the first to add a comment!