コードを見る(AutoLISP)

gp:calculate-Draw-TileRow 関数のコードを見てください。

(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

前出の疑似コードに対応するコードの前に、次のような AutoLISP コードがあります。

(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

タイルを描くのに、ActiveX 関数、entmake 関数、command 関数のいずれを使用するかを、ユーザが指定できるようにしたことを思い出してください。変数 ObjectCreationFunction には、引数 ObjectCreationStyle に応じて、3 つの関数の中の 1 つが割り当てられます( gp:Calculate-and-Draw-Tiles を介して C:GPath から渡されます)。次に、gpdraw.lsp に定義する 3 つの関数を示します。

(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))
)

最初の関数は、ActiveX 関数を使用して円を描き、ActiveX オブジェクトを返します。

2 番目の関数は、entmake を使用して円を描きます。ActiveX オブジェクトに変換された図形名を返します。

3 番目の関数は、command を使用して円を描きます。これも、ActiveX オブジェクトに変換された図形名を返します。