In Lesson 6, you hooked up callback function gp:command-will-start to the reactor event :vlr-commandWillStart. As it currently exists, the function displays some messages and initializes two global variables, *polyToChange* and *reactorsToRemove*, to nil.
- Open your gpreact.lsp file.
the gp:command-will-start function,
add two variables to the setq function
call by modifying it as follows:
;; Reset all four reactor globals to nil.
(setq *lostAssociativity* nil
the remaining code in gp:command-will-start,
up to the last princ function call,
with the following code:
(if (member (setq currentCommandName (car command-list))
'( "U" "UNDO" "STRETCH" "MOVE"
"ROTATE" "SCALE" "BREAK" "GRIP_MOVE"
"GRIP_ROTATE" "GRIP_SCALE" "GRIP_MIRROR")
) ;_ end of member
(setq *lostAssociativity* T)
(princ "\nNOTE: The ")
(princ " command will break a path's associativity .")
) ;_ end of progn
) ;_ end of if
This code checks to see if the user issued a command that breaks the associativity between the tiles and the path. If the user issued such a command, the program sets the *lostAssociativity* global variable and warns the user.
As you experiment with the garden path application, you may discover additional editing commands that can modify the garden path and cause the loss of associativity. Add these commands to the quoted list so that the user is aware of what will happen. When this function fires, the user has started a command but has not selected any entities to modify. The user could still cancel the command, leaving things unchanged.
Topics in this section
- Adding Activity to the Object Reactor Callback Functions
- Designing the gp:command-ended Callback Function
- Handling Multiple Entity Types
- Using ActiveX Methods in Reactor Callback Functions
- Handling Nonlinear Reactor Sequences
- Coding the command-ended Function
- Updating gp:Calculate-and-Draw-Tiles
- Modifying Other Calls to gp:Calculate-and-Draw-Tiles