Method InitializeCalc
InitializeCalc(string, string, string, string, int, int, int)
Initializes the calculator and starts calculating using the specified Calc Library Item
Declaration
void InitializeCalc(string calcFileName, string calcItemName, string variables, string sectionName, int sectionId = 0, int pageWidth = 180, int pageHeight = 260)
Parameters
| Type | Name | Description |
|---|---|---|
| string | calcFileName | File name of the Calc Library file which contains the calc item to calculate |
| string | calcItemName | Item name of the Calc Item to calculate |
| string | variables | Xml string of the variables to initialize the calculator instance with |
| string | sectionName | Initial section name |
| int | sectionId | Initial section identifier |
| int | pageWidth | Output page width in twips, default is 180 twips |
| int | pageHeight | Output page height in twips, default is 260 twips |
Remarks
The fileName and itemName are required and determine the Calc Item in the specified Calc Library which will be calculated. If you want to retrieve the document output when calculating is finished the calc item you calculate must be in the RTF format. Output is obtained by using the GetOutput method.
If the calculator has been used to perform a calculation and you want to save the variables so that they can be used at a later date for re-calculating then you can use the optional variables parameter to initialise the calculator with the previously saved variables.The variables from a previous calculation are retrieved by using the GetVariables method.
//Library file name and item name of calculation to use
string calcFileName = "$(SysLbrDir)Bearing pressure.lbr";
string calcItemName = "Bearing pressures";
//Create Tedds calculator
Calculator calculator = new Calculator();
//Start calculating
calculator.InitializeCalc(calcFileName, calcItemName);
Example which uses the "Bearing pressures for rectangular footings" calculation and specifies the input for the design
//Library file name and item name of calculation to use
string calcFileName = "$(SysLbrDir)Bearing pressure.lbr";
string calcItemName = "Bearing pressures";
//Create calculator and initialize for setting up input variables only
Calculator calculator = new Calculator();
calculator.Initialize();
//Set all required input variables
calculator.Functions.SetVar("Lx", 2000, "mm");
calculator.Functions.SetVar("Ly", 2500, "mm");
calculator.Functions.SetVar("Pz", 150, "kN");
calculator.Functions.SetVar("ex", 600, "mm");
calculator.Functions.SetVar("ey", 550, "mm");
//If all the input required has already been specified you can hide the user interface
//of the calculation using a special variable which is supported automatically by all
//calculations "_CalcUI"
//Uncomment the following line to disable the calculations user interface
//calculator.Functions.SetVar("_CalcUI", 0);
//Get variables as XML string
string variables = calculator.GetVariables();
//Initialize for a second time but this time with calculation to start and variables
calculator.InitializeCalc(calcFileName, calcItemName, variables);
//Query the calculation results
double qmax = calculator.Functions.GetVar("qmax").ToDouble("kN/m^(2)");
double bearing = calculator.Functions.GetVar("BearingPercentage").ToDouble();