查看代码 (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、函数或函数绘制图块(圆圈)的规范吗?变量被分配三个函数之一,具体取决于参数(从和通过传递)。下面是将在 gpdraw.lsp 中定义的三个函数:entmakecommandObjectCreationFunctionObjectCreationStyle C:GPath gp:Calculate-and-Draw-Tiles (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 对象。 第二个函数使用 绘制一个圆。它返回转换为 ActiveX 对象的实体名称。entmake 第三个函数使用 绘制一个圆。它还返回转换为 ActiveX 对象的实体名称。command  | 
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1   苏公网安备32011402011833)
GMT+8, 2025-11-4 14:17
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.