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.
Editor Tools
When you work with the Method Editor, you can insert the code at the cursor position in a Method Editor window. Right-click a tree node in the Editor Tools window, choose from the actions applicable to that node in the model, click one of the corresponding buttons underneath the tree, or double-click or press Enter to insert the top action on the tree node’s context menu.
In the Editor Tools toolbar, click Edit Node (), when available, to open an editor node for moving to the Settings window or an editor window for the selected node. From the Collapse () and Expand () toolbar menus, you can choose Collapse Selected or Expand Selected to collapse or expand the selected tree branches (or use the divide and multiply keypad keys, respectively), Collapse Other to collapse all tree branches except the selected ones, or Collapse All or Expand All to collapse or expand all branches in the tree.
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):
Get (), to insert code to get the value of a parameter, property, or filename (for example, model.param().get("w") or model.component("comp1").geom("geom1").feature("r1").getDouble("rot")), or to insert a reference to the feature (for example, model.geom("geom1").feature("r1")).
Set (), to insert code to set the value of a parameter, property, or filename (for example, model.param().set("w", 0); or model.component("comp1").geom("geom1").feature("r1").set("rot", "0");).
Set All (), to insert code to set all nondefault properties of a feature.
Create (), to insert code to create the feature (for example, model.component("comp1").geom("geom1").create("r1", "Rectangle");).
Run (), to insert code to run the feature (for example, model.sol("sol1").run();).
Enable () or Disable (), to insert code to enable or disable the feature (for example, model.component("comp1").geom("geom1").feature("r1").active(true); to enable that feature).
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 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):
Input (), to insert a Text Label, Input Field, and (if applicable) Unit object to display the name and an input field for a model parameter or a variable under Declarations.
Output (), to insert a Text Label and Data Display object to display the name and value of a model parameter or variable, or for a variable under Declarations.
Graphics (), to insert a Graphics object for a plot group, geometry, or mesh.
Button (), to insert a Button object for a file or view command or to create a report, for example.