gp:calculate-Draw-TileRow function:
Now look at the code for the(defun gp:calculate-Draw-TileRow (startPoint TileRadius
TileSpace pathWidth pathAngle offsetFromCenter
ObjectCreationStyle / HalfWidth TileDiameter
ObjectCreationFunction angp90 angm90
firstCenterPt TileCenterPt TileList)
(setq HalfWidth (- (/ pathWidth 2.00) TileRadius)
Tilespacing (+ (* TileRadius 2.0) TileSpace)
TileDiameter (* TileRadius 2.0)
angp90 (+ PathAngle (Degrees->Radians 90))
angm90 (- PathAngle (Degrees->Radians 90))
firstCenterPt (polar startPoint angp90 offsetFromCenter)
tileCenterPt firstCenterPt
ObjectCreationStyle(strcase ObjectCreationStyle)
ObjectCreationFunction
(cond
((equal ObjectCreationStyle "ACTIVEX")
gp:Create_activeX_Circle
)
((equal ObjectCreationStyle "ENTMAKE")
gp:Create_entmake_Circle
)
((equal ObjectCreationStyle "COMMAND")
gp:Create_command_Circle
)
(T
(alert (strcat "ObjectCreationStyle in function
gp:calculate-Draw-TileRow"
"\nis invalid. Contact developer for assistance."
"\n ObjectCreationStyle set to ACTIVEX"
)
)
setq ObjectCreationStyle "ACTIVEX")
)
)
)
;; Draw the circles to the left of the center.
(while (< (distance startPoint tileCenterPt) HalfWidth)
;; Add each tile to the list to return.
(setq tileList
(cons
(ObjectCreationFunction tileCenterPt TileRadius)
tileList
)
)
;; Calculate the center point for the next tile.
(setq tileCenterPt
(polar tileCenterPt angp90 TileSpacing)
)
);_ end of while
;; Draw the circles to the right of the center.
(setq tileCenterPt
(polar firstCenterPt angm90 TileSpacing))
(while (< (distance startPoint tileCenterPt) HalfWidth)
;; Add each tile to the list to return.
(setq tileList
(cons
(ObjectCreationFunction tileCenterPt TileRadius)
tileList
)
)
;; Calculate the center point for the next tile.
(setq tileCenterPt (polar tileCenterPt angm90 TileSpacing))
);_ end of while
;; Return the list of tiles.
tileList
) ;_ end of defun
The AutoLISP code logic follows the pseudo-code, with the following addition:
(setq ObjectCreationFunction
(cond
((equal ObjectCreationStyle "ACTIVEX")
gp:Create_activeX_Circle
)
((equal ObjectCreationStyle "ENTMAKE")
gp:Create_entmake_Circle
)
((equal ObjectCreationStyle "COMMAND")
gp:Create_command_Circle
)
(T
(alert
(strcat
"ObjectCreationStyle in function gp:calculate-Draw-TileRow"
"\nis invalid. Contact the developer for assistance."
"\n ObjectCreationStyle set to ACTIVEX"
) ;_ end of strcat
) ;_ end of alert
(setq ObjectCreationStyle "ACTIVEX")
)
) ;_ end of cond
) ;_ end of setq
entmake function, or the command function? The ObjectCreationFunction variable is assigned one of three functions, depending on the ObjectCreationStyle parameter (passed from C:GPath and through gp:Calculate-and-Draw-Tiles). Here are the three functions as they will be defined in gpdraw.lsp:
Remember the specification to allow users to draw the tiles (circles) using either ActiveX, the(defun gp:Create_activeX_Circle (center radius)
(vla-addCircle *ModelSpace*
(vlax-3d-point center) ; convert to ActiveX-compatible 3D point
radius
)
) ;_ end of defun
(defun gp:Create_entmake_Circle (center radius)
(entmake
(list (cons 0 "CIRCLE") (cons 10 center) (cons 40 radius))
)
(vlax-ename->vla-object (entlast))
)
(defun gp:Create_command_Circle (center radius)
(command "_CIRCLE" center radius)
(vlax-ename->vla-object (entlast))
)
The first function draws a circle using an ActiveX function and returns an ActiveX object.
entmake. It returns an entity name converted into an ActiveX object.
The second function draws a circle usingcommand. It also returns an entity name converted into an ActiveX object.
The third function draws a circle using