Copy as Code to Clipboard
To create custom methods for an application, you can copy the contents of a node in the embedded model as the corresponding code. If you select nodes in the embedded model and right-click, the context menu contains a Copy as Code to Clipboard submenu. The corresponding functionality is available in the Editor Tools window.
Figure 2-5: The options on the Copy as Code to Clipboard submenu.
The submenu usually contains up to five entries. All entries copy source code to the system clipboard. More specifically:
Create, to generate a code snippet to create the corresponding object.
Get, to generate a code snippet to access the corresponding object.
Set All Modified Settings, to generate a code snippet to set the nondefault properties in the corresponding object.
Set All Displayed Settings, to generate a code snippet to set all available properties in the corresponding object.
Run, to generate a code snippet to run the corresponding sequence.
The Create and Run actions are only applicable for nodes that you can create and that you can run, respectively. Similarly, “set” actions are only available when there are properties that can be set.
Copy as Code to Clipboard > Set All Displayed Settings is not supported for features that are specific to the Application Builder, such as forms and declarations.
When a Derived Values feature node or an Evaluation Group node is selected in the Model Builder, the following four options for generating numeric evaluation code are also available:
Evaluate real scalar, to evaluate a real scalar value.
Evaluate real matrix, to evaluate the values of a real matrix.
Evaluate imaginary scalar, to evaluate an imaginary scalar value.
Evaluate imaginary matrix, to evaluate the value of an imaginary matrix.
If you select more than one node in the model tree, the available options (such as Get, Set All, or Create) are those that are available for all selected nodes. The copied code becomes the concatenation of the code for each of the nodes.
The Copy as Code to Clipboard actions are intended to make it easier to write code. It can sometimes be hard to figure out what code to write to access a particular model entity, but by using Copy as Code to Clipboard > Get and then pasting the result into a Method Editor window, you do not need to know the corresponding code. Similarly, to figure out how to set a particular property in a model entity, you can change the property in the embedded model, use Copy as Code to Clipboard > Set All Modified Settings, paste the result into a Method Editor window, and possibly edit the inserted code. The Create and Run actions provide the same functionality but for the tasks of creating and running the feature, respectively.
Copy as Code to Clipboard > Set All Modified Settings only considers properties that have been changed directly in the feature’s settings. In particular, it does not consider properties set by inserting a geometry sequence. When available, you can instead choose Set All Displayed Settings from the same menu to get code for setting all properties for the feature.
The actions Set All Modified Settings and Set All Displayed Settings can sometimes generate different but equivalent code for the same setting.