找回密码
 [加入论坛]
查看: 1790|回复: 1

增强的OFFSET

[复制链接]
2443725 发表于 2004-11-29 15:33 | 显示全部楼层 |阅读模式
<FONT face=宋体>;; FFS.LSP
;; 增强的OFFSET       
;; BY LUCAS(龙龙仔)
;;1.改成没选中不退出!
;;2.并能连续UNDO
(defun REPCMD ()
  (while (= OBJ "Options")
    (if        (not FIRST)
      (command)
    )
    (setq CVAL (getvar "offsetdist"))
    (if        (minusp CVAL)
      (setq DEF "Through")
      (setq DEF (rtos CVAL))
    )
    (initget "Through")
    (setq
      OPT (getdist (strcat "\nOffset distance or Through&lt;" DEF "&gt;: "))
    )
    (cond ((not OPT) (setq OPT DEF))
          ((numberp OPT) (setq OPT (rtos OPT)))
    )
    (if        (= OPT "Through")
      (setvar "offsetdist" -1)
      (setvar "offsetdist" (read OPT))
    )
    (command ".offset" "")
    (DO_IT)
  )
  (setq FIRST NIL)
)

(defun DO_IT ()
  (initget "Undo Options eXit")
  (setq
    OBJ        (entsel        "\n &lt; Select object to offset &gt;/Undo/Options<EXIT>: "
        )
  )
  (if (= OBJ "Options")
    (REPCMD)
  )
  (while (= OBJ "Undo")
    (if        (&gt; COUNT 0)
      (progn (command)
             (command "_.ERASE" (entlast) "")
             (command "_.OFFSET" "")
             (setq COUNT (1- COUNT))
      )
      (princ "\n 没有可Undo的了!")
    )
    (initget "Undo Options eXit")
    (setq
      OBJ (entsel "\n &lt; Select object to offset &gt;/Undo/Options<EXIT>: "
          )
    )
  )
  (if (= OBJ "Options")
    (REPCMD)
  )
)

;; MAIN FUNCTION
(defun C:FFS (/ CVAL DEF OPT OBJ EN TPT SIDE COUNT FIRST)
  (setvar "cmdecho" 0)
  (setvar "blipmode" 0)
  (setq        OBJ   "Options"
        COUNT 0
        FIRST t
  )
  (REPCMD)
  (while (/= OBJ "eXit")
    (cond
      ((= OPT "Through")
       (initget 1)
       (setq TPT (getpoint "\nThrough point: "))
       (command TPT)
      )
      ((/= OBJ NIL)
       (command (cadr OBJ))
       (initget 1)
       (setq SIDE (getpoint "\nSide to offset? "))
       (command SIDE)
       (setq COUNT (1+ COUNT))
      )
    )
    (DO_IT)
  )
  (command)
  (princ)
)
(princ)
(prompt "Type FFS to run")
</FONT>
 楼主| 2443725 发表于 2004-11-29 15:34 | 显示全部楼层
<FONT face=宋体 size=2>;| fff.lsp=增强的offset,可中途undo
功能:可以 undo;中途改变 偏移距离; (未选中物体不退出)
v1.0
注明: 如要在r14下运行,将 vl-cmdf 改为 command
      没有写出错处理,因为只改offsetdist系统变量,这个变量经常根据需要修改,没有保留恢复的必要
|;

;加载息
(princ "\n fff.lsp=增强offset,可中途undo---------------陌生人.2003.12")
;主程序
(defun c:fff ( / roop do)
  (princ "\n fff.lsp=增强的offset,可中途undo---------------陌生人.2003.12")
  (vl-cmdf ".undo" "be")
  (setq roop T)
  (while roop
    (princ "\n当前偏移距离值:")(princ (getvar "offsetdist"))
    (initget " Undo Dist eXit")
    (setq do (entsel "\n&lt;选择偏移实体&gt;/Undo/Dist-调整偏移距离/eXit(空格或回车):"))
    (cond
      ((= 'LIST (type do)) (vl-cmdf ".offset" "" do (getpoint (cadr do) "\n点选偏移方向:") "" ));选中实体.
      ((= "Undo" do) (vl-cmdf ".u"))
      ((= "Dist" do)  (setvar "offsetdist" (getdist "\n输入新的偏移距离:")) )
      ((or (= "eXit" do)
           (and (= nil do)(= (getvar "errno") 52)))
       (setq roop nil))
    )
  );end while
  (vl-cmdf ".undo" "e")
  (princ)
)</FONT>
回复 顶 踩

使用道具 举报

您需要登录后才可以回帖 登录 | [加入论坛]

本版积分规则

手机版|化工技术网- 赠人玫瑰 手有余香 ( 苏ICP备14035884号 )

GMT+8, 2026-12-1 21:25

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表