Method GetOutput

GetOutput(OutputFormat)

Returns the documented output from the calculator in the specified format.

Declaration
string GetOutput(OutputFormat format = OutputFormat.Rtf)
Parameters
Type Name Description
OutputFormat format

Output format, the default is Microsoft Rich Text Format

Returns
Type Description
string

Output documentation.

Remarks

In order to obtain output the calculator must have been initialized with RTF, using InitializeCalc or Initialize.

If the scenario you are implementing requires both input and output then you will typically initialize the Calculator object twice, the first time to create the input variables for the calculation and the second time to initialise the calculator using those input variables to start a specific calculation.

When the output is requested in PDF format the resulting string must be processed correctly. PDF is a binary format and as such the string should not be modified because it is likely to contain invalid characters and null terminators which will not be processed correctly by most string processing functions. The string should be converted to raw bytes before further processing or saving to disk.

//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");

         //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);

         //Calculation has now finished so retrieve variables
         string outputRtf = calculator.GetOutput();

         //Copy output to Windows clipboard
         Clipboard.SetText(outputRtf, TextDataFormat.Rtf);</code></pre></example>

Was this helpful?
The feedback you give here is not visible to other users. We use your comments to improve the content.
Previous
Next