Working with Methods > Creating Methods > Adding Model Code and Form Objects

Adding Model Code and Form Objects
The Editor Tools window provides code for common model operations (for example, setting all nondefault properties of a feature) and options to create applicable form objects corresponding to a model operation.
Method Editor Tools
When you work in a method editor, you can insert the code at the cursor position in a method editor window. Right-click on a tree node in the Editor Tools window and choose among the different actions, click one of the corresponding buttons underneath the tree, or double-click to insert the top action on the tree node’s context menu.
Figure 4-6: Use the context menu to insert code into the current method.
The following actions are available in the method editor (not all actions are applicable to all nodes):
Choose Get () to insert code to get the value of a parameter, property, or filename (for example, model.param().get("w") or model.geom("geom1").feature("r1").getDouble("rot")), or to insert a reference to the feature (for example, model.geom("geom1").feature("r1")).
Choose Set () to insert code to set the value of a parameter, property, or filename (for example, model.param().set("w", 0); or model.geom("geom1").feature("r1").set("rot", "0");).
Chose Set All () to insert code to set all nondefault properties of a feature.
Choose Create () to insert code to create the feature (for example, model.geom("geom1").create("r1", "Rectangle");).
Choose Run () to insert code to run the feature (for example, model.sol("sol1").run();).
Choose Enable () or Disable () to insert code to enable or disable the feature (for example, model.geom("geom1").feature("r1").active(true); to enable that feature).
Choose Edit Node () to select that node under the Model branch in the main desktop’s Application Builder window and open its Settings window for editing. You can also click the Edit Node button () at the top of the Editor Tools window.
Form Editor Tools
When you work in a form editor, you can insert form objects corresponding to an action or display for a selected item in the tree. Right-click on a tree node and choose among the different form objects or collection of form objects, click one of the corresponding buttons underneath the tree, or double-click to insert the top option on the tree node’s context menu.
The following actions are available in the form editor (not all actions are applicable to all nodes):
Choose Input () to insert a Text Label, an Input Field, and (if applicable) a Unit object to display the name and an input field for a model parameter or a variable under Declarations.
Choose Output () to insert a Text Label and a Data Display object to display the name and value of a model parameter or variable, or for a variable under Declarations.
Chose Graphics () to insert a Graphics object for a plot group, the geometry, or the mesh.
Choose Button () to insert a Button object for a file or view command or to create a report, for example.