明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3608|回复: 16

关于LISP植入R14的问题

  [复制链接]
发表于 2011-10-30 18:23:49 | 显示全部楼层 |阅读模式
我在网上找到一条LISP,左右是复制时数值自动递进的LISP,问题是我用CAD2007用这个LISP就可以用,但是用R14就出现问题,当输入命令时就会有错误:Error: null function*Cancel*——就是这样没了,现在求助高手能不能帮我修改一下LISP可以用在R14上面,谢谢!附源代码
;;下列是通用函数库,因为不是针对单一程序功能,代码可能不是最简的!
(vl-load-com)
(setq *acad* (vlax-get-acad-object))
(setq *doc* (vla-get-ActiveDocument *acad*))

;;取物件dxf码
(defun fsxm-getendxf (en dxf)
  (cdr (assoc dxf (entget en)))
)

;;自标志后新生成的物件列表
(defun fsxm-newenlist (en / lst n ss)
  (if en
    (while (setq en (entnext en))
      (setq lst (cons en lst))
    )
    (setq lst (fsxm-ss->enlist (ssget "X")))
  )
  lst
)

;;自标志后新生成的选择集
(defun fsxm-newSelection (en / ss)
  (cond        (en
         (setq ss (ssadd))
         (foreach a (fsxm-newenlist en) (ssadd a ss))
         ss
        )
        (t (ssget "X"))
  )
)

;;无声退出
(defun fsxm-silenceexit        (/ *error*)
  (t (setq *error* strcat))
)

;;选择集转化为表
(defun fsxm-ss->enlist (ss / lst n en)
  (setq n -1)
  (while (setq en (ssname ss (setq n (1+ n))))
    (setq lst (cons en lst))
  )
)

;;=========================下面是主程序罗!==========================
(defun c:TextCopy+ (/ *error* enp la n opt ss)
  (princ "\n!本功能只递增尾部为数字或字母的文字!")
  (setq ss (ssget ":S"))
  (or ss (fsxm-silenceexit))
  (sssetfirst nil ss)

  (setq n (getreal "\n输入增量值<1>:"))
  (or n (setq n 1))

  ;;增量复制
  (defun CopyText+ (en n / new real s1 s2 s2+ str)
    (setq str (fsxm-getendxf en 1))
    (or str (setq str ""))
    (cond ((wcmatch str "*[a-zA-Z]")
           (setq s1 (substr str 1 (1- (strlen str))))
           (setq s2 (substr str (strlen str)))
           (setq s2+ (+ n (ascii s2)))
           (cond ((wcmatch (chr s2+) "@"))
                 ((> s2+ (ascii "z")) (setq s2+ 97)) ;122
                 ((> s2+ (ascii "Z")) (setq s2+ 65)) ;90
           )
           (setq new (vla-copy (vlax-ename->vla-object en)))
           (vla-put-TextString new (strcat s1 (chr s2+)))
           (entlast)
          )
          ((wcmatch str "*#")
           (setq s1 "")
           (while (not (numberp (vl-catch-all-apply 'read (list str))))
             (setq s1 (strcat s1 (substr str 1 1)))
             (setq str (substr str 2))
           )
           (setq real (vl-princ-to-string (+ n (read str))))
           (setq new (vla-copy (vlax-ename->vla-object en)))
           (vla-put-TextString new (strcat s1 real))
           (entlast)
          )
          (t
           (vla-copy (vlax-ename->vla-object en))
           (entlast)
          )
    )
  )
  (vla-StartUndoMark *doc*)
  (setq opt (getpoint "\n指定基准点:"))
  (or opt (fsxm-silenceexit))
  (setvar "lastpoint" opt)
  (defun *error* (msg)
    (mapcar 'entdel (fsxm-ss->enlist ss))
    (vla-EndUndoMark *doc*)
  )
  (setvar "cmdecho" 0)
  (while t
    (setq la (entlast))
    (foreach en (fsxm-ss->enlist ss) (CopyText+ en n))
    (setq ss (fsxm-newselection la))
    (setq opt (getvar "lastpoint"))
    (command ".move" ss "" "non" "@" "\\")
    (if        (equal opt (getvar "lastpoint") 1e-8)
      (exit)
    )
  )
  (vla-EndUndoMark *doc*)
  (princ)
)



谢谢大家,本人纯属LISP文盲,希望大家能指点一下,为什么会有这样情况与解决方案,万分感谢!
发表于 2011-10-30 19:06:09 | 显示全部楼层
R14不支持vl系列函数,2000版以后才支持!
 楼主| 发表于 2011-10-30 19:08:47 | 显示全部楼层
Gu_xl 发表于 2011-10-30 19:06
R14不支持vl系列函数,2000版以后才支持!

那么想问一下有没有办法将这段程序改成R14能用的?谢谢
发表于 2011-10-30 19:34:04 | 显示全部楼层
你可以直接找作者,就在明经论坛里
 楼主| 发表于 2011-10-30 21:38:38 | 显示全部楼层
cabinsummer 发表于 2011-10-30 19:34
你可以直接找作者,就在明经论坛里

麻烦给我介绍一下好吗,谢谢,因为我在其他地方找回来的。谢谢
发表于 2011-10-30 21:57:51 | 显示全部楼层
qq229918602 发表于 2011-10-30 21:38
麻烦给我介绍一下好吗,谢谢,因为我在其他地方找回来的。谢谢

去找几个版主,他们都认识。你就问哪位大侠在自己的自定义函数加前缀“fsxm-”
发表于 2011-10-30 22:30:30 | 显示全部楼层
R14是经典,大家都难以忘记
cad建议用用新版本哦
 楼主| 发表于 2011-10-30 22:54:42 | 显示全部楼层
gbhsu 发表于 2011-10-30 22:30
R14是经典,大家都难以忘记
cad建议用用新版本哦

公司就是用这个,没办法。。谁叫公司只能用正版。
发表于 2011-10-30 23:00:26 | 显示全部楼层
R14上有个vlisp试用版,上网下个试试。
发表于 2011-10-31 00:45:17 | 显示全部楼层
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-9-25 05:45 , Processed in 0.158768 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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