Beispielscript
Das folgende Beispielscript führt folgende Aktionen aus:
- Berechnungsschalter für die Gesamtsystemberechnung werden gesetzt
- Drehmoment der ersten Belastung wird auf 500 Nm gesetzt
- Gesamtsystemberechnung wird ausgeführt
- Ergebnisattribute auf der Komponente "cylindrical_mesh" (für alle Stufen im Getriebe) lesen
- Ergebnisattribute werden in die ASCII-Datei geschrieben
- Ergebnisattribute auf der Komponente "notch" (für alle Kerbstellen im Getriebe) lesen
- Ergebnisattribute werden in die ASCII-Datei geschrieben
- HTML Report wird generiert
Das Beispielscript kann auf beliebige Getriebemodelle angewendet werden. Voraussetzung für eine korrekte Berechnung ist die Vollständigkeit der Eingabedaten.
////////////////////////////////////////////////////////////////////////////////
// Script to present the Job/Scripting capability
// Version 1.0
// Date 26.06.2018
/////////////////////////////////////////////////////////////////////////////////
// Pfade für ASCII Ausgabedatei / Reportvorlage / Reportausgabedatei
// ASCII output file / report template / report output file
ASCII_ResultFile = "C:\\example_folder\\output\\result.txt";
HTML_ResultFile = "C:\\example_folder\\output\\result.html";
HTML_Template = "C:\\example_folder\\input\\report_template.wbrep";
Torque = 500
// ASCII Datei leeren
// Empty ASCII file
clearOutput();
// Variable für die Komponenten-ID der Getriebeeinheit
// Variable for the component ID of the gear unit
var gearUnit = getCompByType('gear_unit')[0];
// Berechnungsschalter für die Gesamtsystemberechnung setzten
// Set calculation switches for the system calculation
setAttr( 'gta_switch_geometry_output' , gearUnit, 'true', EDAT); // Schalter Geometrieberechnung | Switch geometry calculation
setAttr( 'gta_switch_3d_load_distribution_analytical', gearUnit, 'true', EDAT); // Schalter 3D-Lastverteilung | Switch 3D Load distribution
setAttr( 'gta_switch_bearing_lifetime' , gearUnit, 'true', EDAT); // Schalter Lagerlebensdauer | Switch Bearing lifetime
setAttr( 'gta_switch_din_743' , gearUnit, 'true', EDAT); // Schalter Wellensicherheit | Switch Shaft safety
// Variable mit der Komponenten-ID der ersten Belastung im Getriebe
// Variable with the component ID of the first force in the gearbox
var input_force = getCompByType('force')[0];
// Setzt das Drehmoment der ersten Belastung
// Sets the torque of the first force
setAttr('scaled torque', input_force, Torque, EDAT);
writeOutput(Torque+' Nm input torque used for calculation');
// Überschrift in ASCII Datei schreiben
// Write heading to ASCII file
writeOutput('------ Output System Calculation -----');
// Gesamtsystemberechnung starten
// Start system calculation
runCalcMethod('001_SYSTEM_CALCULATION', '1');
writeOutput('------ Cylindrical Stages -------');
// Array mit den Komponenten ID's aller Stirnradstufen
// Array with the component ID's of all Cylindrical meshes
var stageIds = getCompByType('cylindrical_mesh');
// for-Schleife, die Attribute für jede Stufe liest und in die ASCII Datei schreibt
// for loop reads the attributes for each mesh and writes them to the ASCII file
for (var i=0; i < stageIds.length; i++)
{
var total_contact_ratio = getAttr("total contact ratio" , stageIds[i] ,0);
var transverse_contact_ratio = getAttr("transverse contact ratio", stageIds[i] ,0);
var overlap_contact_ratio = getAttr("overlap contact ratio" , stageIds[i] ,0);
writeOutput(getCompProperty(stageIds[i],'NAME'));
writeOutput("\t total contact ratio = " + total_contact_ratio);
writeOutput("\t transverse contact ratio = " + transverse_contact_ratio);
writeOutput("\t overlap contact ratio = " + overlap_contact_ratio + "\n");
}
writeOutput('------------- Notches --------------------');
var notchIds = getCompByType('notch');
// for-Schleife die Attribute für jede Kerbstelle liest und in die ASCII Datei schreibt
// for loop reads the attributes for each notch and writes them to the ASCII file
for (var i=0; i < notchIds.length; i++)
{
var S_F = getAttr("safety_factor_S_F", notchIds[i] ,0);
var S_D = getAttr("safety_factor_S_D", notchIds[i] ,0);
writeOutput(getCompProperty(notchIds[i],'NAME'));
writeOutput("\t S_F = " + S_F + " | S_D = " + S_D);
}
// HTML Report mit mehreren Optionen generieren
// result variable enthält die Information ob der Report erfolgreich erstellt wurde
// Generate HTML report with several options
// result variable contains the information whether the report was created successfully or not
var result = generateReport(HTML_Template, HTML_ResultFile, {compactView: false, language: "en", completeTree: false, notifications: true, navigationBar: true});
// Popup Box mit Meldung "Report generated successfully" wenn result variable = 1
// Popup box with message "Report generated successfully" if result variable = 1
if(result == 1) { alert('Report generated successfully') }
else { alert('Could not create HTML report') }
// Hilfsfunktionen
// Support functions
function writeOutput(text) {
writeToFile( ASCII_ResultFile, text + '\n', 'a' );
println( text );
}
function clearOutput() {
writeToFile( ASCII_ResultFile, "", 'c' );
}