Appendix E — Built-In Method Library
This appendix lists all of the built-in methods available in the Method Editor, except for methods that operate on the model object and the application object. For detailed information on using the built-in methods and for full information on the syntax used, see the Application Programming Guide and the Programming Reference Manual.
As an alternative method of learning the syntax of these methods, you can use code completion by typing the name of the method and then use Ctrl+Space. A window will open with information on the syntax and method signature.
Model Utility Methods
The model utility methods make it possible to load the model object part of an MPH-file into a method for further processing.
File Methods
The file methods support, in addition to reading and writing to data files on the file system, reading and writing of data files stored in a Model Manager database by accepting a file location URI.
Returns a CsReader object that can be used to read line-by-line or character-by-character from a given file name.
Returns a CsBinaryReader object that can be used to read from a given file byte-by-byte.
Writes array data to a given file. If the spreadsheet format is used, then the data can be read by readMatrixFromFile or readStringMatrixFromFile.
Returns a CsWriter object that can write to a given file.
Returns a CsBinaryWriter object that can be used to write to a given file byte-by-byte.
Displays a file browser dialog and uploads the selected file to the file declaration with the given name. Alternatively, it uploads the selected file to the Filename text field in a given model object entity.
Writes the given string array data starting from a specified cell in a specified sheet of an Excel file.
This method can be used to pass the path to, for example, a file using the temp:/// scheme to external code or an application.
Operating System Methods
Email Methods
Email Class Methods
The class EmailMessage can be used to create custom email messages.
Creates a new EmailMessage object.
Email Preferences
To set preferences for an outgoing email (SMTP) server, open the Email page of the Preferences window, as shown in the figure below.
COMSOL Server provides a similar set of email preferences.
GUI-Related Methods
Shows the form with the given name in the current main window. In a single window application, the form replaces the current one. In an application with subwindows, the form must exist in the main window layout. If not, it will not be opened. Showing a form that is already open will only activate the form.
Closes the form with the given name. Closing forms is only possible in applications using subwindows. This method is not applicable for single window applications.
Shows the values from the tableFeature in the resultsTable form object.
Returns an object of the type ChoiceList, representing a choice list node under the declarations branch. The type ChoiceList has associated methods that make it easy to change values and display names, see the Application Programming Guide.
Sets the enable state for the menu bar item specified by the name or name path (from the menu bar) in the first argument.
GUI Command Methods
Debug Methods
Methods for External C Libraries
External Method
Methods Returned by the External Method
The external method returns an object of type External with the following methods:
Progress Methods
Removes all progress levels and resets progress to 0 and the message to an empty string.
Date and Time Methods
You can use the timeStamp method to record time differences and then set the measured time in ms (a long integer).
License Methods
Conversion Methods
Converts strings and string arrays to Booleans. ('true' returns true, all other strings return false).
Array Methods
String Methods
Collection Methods
With, Get, and Set Methods
Model Builder Methods for Use in Add-ins
For writing add-in method code that operates on the current component, current mesh, current physics, and so on, use the methods in the table below.
Returns an object of the type ModelNode for the current component.
Returns an object of the type Physics for the current physics interface.
Returns an object of the type MeshSequence for the current mesh.
Returns an object of the type Study for the current component.
Returns an object of the type ResultFeature for the current component.
Returns an object of the type ModelEntity for the current component.
These methods return the corresponding entity such that the method code in an add-in can operate on it. When called from an application a method in this category returns null. Also, null is returned if no entity of the corresponding type exists such that nothing is current.