This feature allows editing of the pre-update and post-update scripts associated with a FRED document. When a change is made to a FRED model, the document being modified undergoes an update cycle. The update cycle is a process that ensures the integrity of the model by applying the requested changes to the internal database after accounting for all of the complex interdependencies between elements. At a high level, the update cycle takes the following steps when triggered (by hitting Apply or OK on a dialog in the GUI or by calling the Update subroutine from scripting):
In the context of the update cycle, the pre-update script will execute and operate on the current state of the document, the document undergoes the FNode Tree Update and Property Updates, and then the post-update script will execute and operate on the new state of the document.
Suppose that the user wanted to construct a model in which the center of curvature for surface A is always centered on surface B. Such a dependency requires that if the position of surface B is ever modified, surface A is automatically updated without requiring the user's interaction. In this context, a post-update script can be written which checks the current location of surface B and then modifies the center of curvature for surface A as required. The post-update script will then be executed every time the model finishes the update cycle and the desired dependency between surface A and B is always valid without specific interaction by the user.
Another very common usage of pre and post update scripts is to pair them with the Global Script Variables in order to facilitate parameterization of the model through the GUI. The pre-update script would check the global script variable values and modify the corresponding elements as required at the start of the update cycle.
This feature can be accessed by selecting Tools > Edit/View Pre/Post-Update Script from the menu.
Calling Update from Pre and Post Update Scripts The Update command cannot be executed from a Pre-Update script. It is quite common to setup post-update scripts that themselves modify entities within the document. However, keep in mind that the post-update script is executed at the END of the update cycle. If the user writes a post-update script that itself modifies the document, the post-update script should call the Update command at the end (otherwise the changes will not be committed). When an Update call is issued from a post-update script, the pre and post update scripts will not be executed a second time.
Global Script Variables dialog
|
||||||||||||||||||||||||||||||||||||||||||||||||