Renamed Methods
The COMSOL API can have methods with the same name resulting in different operations, for example the methods that can get and set properties. This is not allowed by the COM requirements. To avoid conflicts, methods are renamed as described in this section.
Methods that Get and Set Properties
In the COMSOL API you can get and set properties with the same method name. In the COMSOL API for VBA the methods to get properties are appended the prefix get_ to their name, while the name of the methods that set properties are using the same name as in the COMSOL API for Java.
For example, the method author() can return the author name of a node in the model using the syntax:
String author()
But it can also set the author’s name of the node in the model using the syntax:
ModelEntity author(String name)
As a standard, the methods used for getting the value of a property is appended with the prefix get_. The methods used for setting the value of a property keep their name in the COMSOL API.
Thus to run the first method above in VBA you can type:
string get_author()
While to run the second method in VBA, use the same syntax:
ModelEntity author(string name)
Some of the methods that have been renamed in this way are:
string tag();
string label();
string comments();
String author();
string version();
string model();
Methods that Retrieve Nodes
Methods that are used to retrieve nodes from the model tree can return a list of all available nodes, or can return a requested node. To avoid conflict in VBA, the method to retrieve a specific node is appended with the prefix get_, while the method that returns all available nodes is the same as in the COMSOL API for Java.
For example, the COMSOL API syntax to return a list that contains all the studies in the model is the following:
StudyList study()
You can type the same command in VBA to retrieve the list of available study nodes:
StudyList study()
The COMSOL API command to return the study specified by tag is:
Study study(String tag)
To do the same in the COMSOL API in VBA type instead:
Study get_study(String tag)
The following command in the COMSOL API sets the input selection of the mesh size node to a point:
model.mesh("mesh").feature("size").selection().geom("geom",0)
To do the same in VBA the feature method is appended with the get_ prefix:
Call model.get_mesh("mesh").get_feature("size").Selection.geom("geom",0)
Methods that return Arrays Or Vectors
The method getAdj() returns an array or a vector depending on the number of arguments. The method that returns an array is renamed to getAdj1 and the method that returns a vector is renamed into getAdj2.
A similar naming convention is applied to the method getAdjOrient. The method that returns an array is renamed to getAdjOrient1, and the method that returns a vector is renamed into getAdjOrient2.