Calculator.GetOutput

Updated: 17 Jan 2024

Calculator.GetOutput 

Gets the output item from the calculator. 

 

Syntax 

GetOutput( format ) 

 

Parameters 

                                                                                                                                                                                    

            

format

            
     Optional output format, the default is Microsoft Rich Text Format (RTF=1) but PDF format (PDF=2) is also supported.      
     
     

 

 

Return Value 

A string containing the output item. 

 

Remarks 

In order to obtain output the calculator must have been initialized with an RTF InputItem, refer to the Calculator.Initialize documentation for more details.  


If the scenario you are implementing requires both input and output then you will typically require two instances of the Calculator object, the first to create the input for the calculation and to obtain the RTF of the calculation you want to use and the second which is initialized with that RTF and the input variables.  


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 (C# - important semicolons may be hidden when viewed in Tedds)

//Example which uses Co-ordinates calculation in Engineerinug Library //Library file name and item name of calculation to use string calcFileName = "$(SysLbrDir)coordinates.lbr"; string calcItemName = "10 coordinates;Calcs"; 
//Create first instance for retrieving RTF and setting input variables Calculator calculator = new Calculator(); calculator.Initialize(); 

//Use Tedds function "GetCalcItemText" to get RTF Input/Output for calculation
Tedds 2019 – API Reference
ICalcValue calcItemRtf = calculator.Functions.Eval(string.Format("GetCalcItemText( \"{0}\", \"{1}\" )", calcFileName, calcItemName)); //Decode Tedds string encoding in the RTF string rtf = calcItemRtf.ToString(); rtf = rtf.Replace("\\\"", "\""); rtf = rtf.Replace("\\;", ";"); 

//Set all required input variables calculator.Functions.SetVar("E", 75, "m"); calculator.Functions.SetVar("N", 100, "m"); 

//Get variables as XML string string variables = calculator.GetVariables(); 

//Initialize second calculator but this time with input/output RTF and variables Calculator calculator2 = new Calculator(); calculator2.Initialize(rtf, variables); string outputRtf = calculator2.GetOutput(); 

//Copy output to Windows clipboard Clipboard.SetText(outputRtf, TextDataFormat.Rtf); Calculator.GetVariables( format ) 

 

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