gp:Calculate-and-Draw-Tiles to use ActiveX to create objects when invoked from a reactor callback. This means overriding the object creation style (ActiveX, entmake, or command) chosen by the user, if necessary. The code you just updated, in the gp:command-ended function, contains the following invocation of the tile drawing routine:
Earlier in this lesson, it was noted that you need to force(setq tileList (gp:Calculate-and-Draw-Tiles
;; path data list without correct tile list.
NewReactorData
;; Object creation function.
;; Within a reactor this *MUST* be ActiveX.
"ActiveX"
)
)
gp:Calculate-and-Draw-Tiles: NewReactorData (which is a list in the form of the original gp_PathData association list) and the string "ActiveX" (which will set the object creation style). But take a look at the current definition of gp:Calculate-and-Draw-Tiles. (In case you have forgotten, this function is defined in gpdraw.lsp.) Here is the part of the function that declares the parameters and local variables:
Two parameters are passed to(defun gp:Calculate-and-Draw-Tiles (BoundaryData /
PathLength TileSpace
TileRadius SpaceFilled
SpaceToFill RowSpacing
offsetFromCenter rowStartPoint
pathWidth pathAngle
ObjectCreationStyle TileList)
ObjectCreationStyle is identified as a local variable. Review how the ObjectCreationStyle variable is set, which is a little farther into the function:
Notice only that one parameter is currently specified, and(setq ObjectCreationStyle (strcase (cdr (assoc 3 BoundaryData))))
ObjectCreationStyle is currently set internally within the function by retrieving the value tucked away in the BoundaryData variable (the association list). But now you need to be able to override that value.
TheTo modify gp:Calculate-and-Draw-Tiles to accept an object creation style argument
defun statement for the function should look like the following:
The(defun gp:Calculate-and-Draw-Tiles (BoundaryData
ObjectCreationStyle
/ PathLength TileSpace
TileRadius SpaceFilled
SpaceToFile RowSpacing
offsetFromCenter rowStartPoint
pathWidth pathAngle
TileList) ; remove ObjectCreationStyle from locals
ObjectCreationStyle as both a parameter and a variable, then use the VLISP syntax checking tool on the gp:Calculate-and-Draw-Tiles function, the following message will appear in the Build Output window:
Note that if you declare a variable both as a parameter (before the slash) and as a local variable (after the slash), VLISP will point this out to you. For example, if you declare; *** WARNING: same symbol before and after / in arguments list: OBJECTCREATIONSTYLE
(setq
PathLength (cdr (assoc 41 BoundaryData))
TileSpace (cdr (assoc 43 BoundaryData))
TileRadius (cdr (assoc 42 BoundaryData))
SpaceToFill (- PathLength TileRadius)
RowSpacing (* (+ TileSpace (* TileRadius 2.0))
(sin (Degrees->Radians 60))
)
SpaceFilled RowSpacing
offsetFromCenter 0.0
offsetDistance /(+(* TileRadius 2.0)TileSpace)2.0)
rowStartPoint cdr (assoc 10 BoundaryData))
pathWidth cdr (assoc 40 BoundaryData))
pathAngle cdr (assoc 50 BoundaryData))
) ;_ end of setq
(if (not ObjectCreationStyle)
(setq ObjectCreationStyle (strcase (cdr (assoc 3 BoundaryData))))
)
ObjectCreationStyle has been removed. The code now checks to see if a value has been provided for ObjectCreationStyle. If ObjectCreationStyle is not set (that is, the value is nil), the function assigns it a value from the BoundaryData variable.
The original assignment statement forgp:Calculate-and-Draw-Tiles.
There is one more series of changes you need to make to