明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 6991|回复: 6

【求助】错误: Visual LISP command document mismatch

[复制链接]
发表于 2012-8-15 13:00 | 显示全部楼层 |阅读模式
自己集合的一个lisp工具,在cad08中运行正常。我的程序命令都有ark_前缀,然后通过自定义的pgp文件进行命令简化。在2012中,在第一张打开的图形中能够正常运行,在随后打开的文档中使用简化命令就会提示:错误: Visual LISP command document mismatch
完整的cad的命令可以正常运行。我在论坛中看到说是定义的内部命令,不支持多文档之间切换。
但是我安装 xshrimp大哥的工具箱就没有问题, xshrimp大哥的程序也进行了命令简化,运行正常。希望高人帮帮小弟。谢谢。

"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2015-9-20 21:12 | 显示全部楼层
本帖最后由 edata 于 2015-9-24 20:39 编辑

新版反应器不能跨文件执行,构建的vlr-documentBecameCurrent反应器,只能在当前文档执行,
而vla-add-cmd构建命令之后,在新旧文档都存在这个命令。不过新文件的命令没有函数的支持,造成命令不匹配,所以提示 Visual LISP command document mismatch 。解决方式是(vlax-remove-cmd shortCMD);删除已定义的命令.然后重新定义。
反应器无效,所以建议采用启动组的方式加载这个lisp,或者acad.lsp。总之能启动这个lisp就能加载自定义命令。
2015年9月24日20:38:41
因为没了反应器,所以会造成前面的文档无法使用,因此直接更改为defun版。
  1. ;;;********************************
  2. ;;; 工具快捷命令初始化 函数
  3. ;;;********************************
  4. (defun C:ark_qgqc (/ PGPFile fp i xString aList shortCMD GlobalCMD)
  5. (princ"\n自定义文件已经重新加载!")
  6.   (vl-load-com)
  7.   (setq PGPFile "Arktools.pgp")                ;
  8.   (if (setq PGPFile (findfile PGPFile))
  9.     (progn                                ;then
  10.       (setq fp (open PGPFile "r"))
  11.       (setq i 1)
  12.       (while (setq xString (read-line fp))
  13.         (if (= (type xString) 'SYM)
  14.           (setq xString (vl-symbol-name xString))
  15.         )                                ;转换数据文件中无引号的字符串.
  16.         (while (vl-string-search " " xstring) ;去掉所有的空格.
  17.           (setq xString (vl-string-subst "" " " xstring)) ;空格.
  18.           (setq xString (vl-string-subst "" "        " xstring)) ;tab符.
  19.         )                                ;end_while
  20.         (if (and (/= (substr xString 1 1) ";")
  21.                  (vl-string-search "," xstring)
  22.                  (vl-string-search "*" xstring)
  23.             )
  24.           (progn
  25.             (setq aList
  26.        (read (strcat "("
  27.          (vl-string-subst " . C:" ",*" xString)
  28.          ")"
  29.        )
  30.        )
  31.       )
  32.             (setq shortCMD
  33.                    (vl-string-trim " " (vl-symbol-name (car aList)))
  34.             )
  35.             (setq GlobalCMD (cdr aList))
  36.             ;(vlax-remove-cmd shortCMD);删除已定义的命令.      
  37.             ;(vlax-add-cmd shortCMD GlobalCMD)
  38.       (eval(read(strcat "(defun c:" (vl-symbol-name (car aList)) "() (" (vl-symbol-name (cdr aList)) "))")))      
  39.           )                                ;end_progn
  40.         )                                ;end_if
  41.         (setq i (+ i 1))
  42.       )                                        ;end_while read-line
  43.       (close fp)
  44.     )                                        ;end_progn then
  45.     (princ
  46.       "\n工具简化命令定义文件 Arktools.pgp 没找到或不存在!"
  47.     )
  48.   )                                        ;end_if

  49.   (setvar "RE-INIT" 16)


  50. )                                        ;end_defun

  51. (C:ark_qgqc)                                ;调用工具快捷命令自动加载函数.
回复 支持 1 反对 0

使用道具 举报

 楼主| 发表于 2012-8-15 13:11 | 显示全部楼层
本帖最后由 smartstar 于 2012-8-16 12:42 编辑

我用的自定义快捷命令程序:


忘记是谁写的了,但在这里表示感谢。

;;;********************************
;;; 工具快捷命令初始化 函数
;;;********************************
(defun C:ark_qgqc (/ PGPFile fp i xString aList shortCMD GlobalCMD)
; (princ"\n自定义文件已经重新加载!")
  (vl-load-com)
  (setq PGPFile "Arktools.pgp")                ;
  (if (setq PGPFile (findfile PGPFile))
    (progn                                ;then
      (setq fp (open PGPFile "r"))
      (setq i 1)
      (while (setq xString (read-line fp))
        (if (= (type xString) 'SYM)
          (setq xString (vl-symbol-name xString))
        )                                ;转换数据文件中无引号的字符串.
        (while (vl-string-search " " xstring) ;去掉所有的空格.
          (setq xString (vl-string-subst "" " " xstring)) ;空格.
          (setq xString (vl-string-subst "" "        " xstring)) ;tab符.
        )                                ;end_while
        (if (and (/= (substr xString 1 1) ";")
                 (vl-string-search "," xstring)
                 (vl-string-search "*" xstring)
            )
          (progn
            (setq aList
                   (read (strcat "("
                                 (vl-string-subst " . C:" ",*" xString)
                                 ")"
                         )
                   )
            )
            (setq shortCMD
                   (vl-string-trim " " (vl-symbol-name (car aList)))
            )
            (setq GlobalCMD (cdr aList))
                                        ;(vlax-remove-cmd shortCMD);删除已定义的命令.
            (vlax-add-cmd shortCMD GlobalCMD)
          )                                ;end_progn
        )                                ;end_if
        (setq i (+ i 1))
      )                                        ;end_while read-line
      (close fp)
    )                                        ;end_progn then
    (princ
      "\n工具简化命令定义文件 Arktools.pgp 没找到或不存在!"
    )
  )                                        ;end_if

  (setvar "RE-INIT" 16)


)                                        ;end_defun

;;;┏━━━━━━━━━━━━━━━━┓
;;;┃工具快捷命令自动加载(反应器调用)┃
;;;┗━━━━━━━━━━━━━━━━┛
(C:ark_qgqc)                                ;调用工具快捷命令自动加载函数.
(defun ayLoadSCMDReactor ()                ;建立AutoCAD文档级反应器.
  (vl-load-com)
  (if (not #AY_LOADSCMDREACTOR)
    (setq #AY_LOADSCMDREACTOR
           (vlr-docmanager-reactor
             nil
             '((:vlr-documentBecameCurrent
                .
                AI:aySCMDCallBack
               )
              )
           )
    )
  )                                        ;end_if
  (defun AI:aySCMDCallBack (aReactor bList) (C:ark_qgqc))
;;;定义反应器的回调函数.
)                                        ;end_defun
(or #AY_LOADSCMDREACTOR (ayLoadSCMDReactor)) ;自动加载反应器.




发表于 2014-5-18 15:33 | 显示全部楼层
同样问题,关注。。。
发表于 2015-9-24 21:21 | 显示全部楼层
已解决,暂未发现新的问题,感谢楼上的热心帮助。
发表于 2016-3-30 17:18 | 显示全部楼层
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-7-5 14:48 , Processed in 0.157171 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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