明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1427|回复: 4

CAD2002与CAD14的区别

[复制链接]
发表于 2005-3-25 13:27 | 显示全部楼层 |阅读模式
一段程序在R14中运行很好,但是在R2002中却不能运行,运行后的结果是:; error: An error has occurred inside the *error* functionbad argument type:
stringp nil,不知为什么?请指教!
发表于 2005-3-25 15:43 | 显示全部楼层
一般没什么区别,要看看你的程序才好说
 楼主| 发表于 2005-3-28 13:40 | 显示全部楼层
程序如下: (defun mod_att(ent id dxf_item)

(while (and (/= "ATTRIB" (car (entgetf '(0) ent))) (/= id (car (entgetf '(2) ent))))
(setq ent (entnext ent))
); while
((lambda (x)
(mapcar '(lambda (y)
(setq x (subst y (assoc (car y) x) x))
); lambda
dxf_item
); mapcar
(entmod x)
(entupd ent)
); lambda
(entget ent)
)
); defun mod_att ;----------------------------------------------------------------------------
; Check layer status, return a association list which contains layer information
;----------------------------------------------------------------------------
(defun laychk(lay / l_sta)
( (lambda (x)
(if (not l_s)
(setq l_s (list (cons x (logand 5 (cdr (assoc 70 (tblsearch "LAYER" x)))))))
); if
); lambda
(getvar "CLAYER")
)
(if (not (tblsearch "LAYER" lay))
(progn
(initget "Yes No")
(if (= (setq l_sta (getkword "\n图层不存在,是否建立该图层 ?\(Y/N\)")) "Yes")
(progn
(command "_.layer" "n" lay "")
(setq l_sta 0)
); progn
); if
); progn
(progn
(setq l_sta (logand 5 (cdr (assoc 70 (tblsearch "LAYER" lay)))))
(if (= 1 (logand 1 l_sta))
(progn
(initget "Yes No")
(if (= (getkword "\n该图层被冻结,是否解冻 ?\(Y/N\)") "Yes")
(command "_.layer" "t" lay "")
(setq l_sta "No")
); if
); progn
); if
(if (numberp l_sta)
(if (= 4 (logand 4 l_sta)) (command "_.layer" "u" lay "")); if
); if
); progn
); if
( (lambda (x)
(cond
( (not x)
(setq l_s (cons (cons lay l_sta) l_s))
)
( (= "No" (cdr x))
(setq l_s (subst (cons lay l_sta) x l_s))
)
( T l_s)
); cond
); lambda
(assoc lay l_s)
) ); defun chklay ;----------------------------------------------------------------------------
; Restore layer status according to association list l_s
;----------------------------------------------------------------------------
(defun layres()
(setvar "CLAYER" (car (last l_s)))
(repeat (length l_s)
( (lambda(x)
(if (numberp (cdr x))
(progn
(if (= 4 (logand 4 (cdr x)))
(command "_.layer" "lo" (car x) "")
); if
(if (= 1 (logand 1 (cdr x)))
(command "_.layer" "f" (car x) "")
); if
); progn
); if
); lambda
(car l_s)
)
(setq l_s (cdr l_s))
); repeat
); layres ;----------------------------------------------------------------------------
; Get DXF codes
;----------------------------------------------------------------------------
(defun entgetf (index ent)
((lambda (e)
(mapcar '(lambda (x)
(cdr (assoc x e))
); lambda
index) ; internal lambda function
); lambda
(entget ent)
)
); defun entgetf ;----------------------------------------------------------------------------
; Save UNDO status
;----------------------------------------------------------------------------
(defun undo_init (/ cmdecho undo_ctl)
(setq cmdecho (getvar "CMDECHO") undo_ctl (getvar "UNDOCTL")) ; Save the value
(setvar "CMDECHO" 0) (if (equal 0 undo_ctl) ; Make sure undo is fully enable
(command "_.undo" "_all")
(command "_.undo" "_control" "_all")
) (if (equal 4 (logand 4 (getvar "UNDOCTL"))) ; Ensure undo auto is off
(command "_.undo" "_auto" "_off")
) (while (equal 8 (logand 8 (getvar "UNDOCTL"))) ; Place an end mark here
(command "_.undo" "_end")
) (while (not (equal 8 (logand 8 (getvar "UNDOCTL"))))
(command "_.undo" "_group")
) (setvar "CMDECHO" cmdecho)
undo_ctl
); defun undo_init ;----------------------------------------------------------------------------
; Restore UNDO status
;----------------------------------------------------------------------------
(defun undo_restore (/ cmdecho)
(if old_undoctl
(progn
(setq cmdecho (getvar "CMDECHO"))
(setvar "CMDECHO" 0) (if (equal 0 (getvar "UNDOCTL")) (command "_.undo" "_all"))
(while (equal 8 (logand 8 (getvar "UNDOCTL")))
(command "_.undo" "_end")
); while
(if (not (equal old_undoctl (getvar "UNDOCTL")))
(progn
(cond
((equal 0 old_undoctl)
(command "_.undo" "_control" "_none")
)
((equal 2 (logand 2 old_undoctl))
(command "_.undo" "_control" "_one")
)
)
(if (equal 4 (logand 4 old_undoctl))
(command "_.undo" "_auto" "_on")
(command "_.undo" "_auto" "_off")
)
)
)
(setq old_undoctl nil)
(setvar "CMDECHO" cmdecho)
)
)
); defun undo_restore ;----------------------------------------------------------------------------
; Save variables
;----------------------------------------------------------------------------
(defun var_save (a)
(setq m_lst '())
(repeat (length a)
(setq m_lst (append m_lst (list (list (car a) (getvar (car a))))))
(setq a (cdr a))
)
); defun var_save ;----------------------------------------------------------------------------
; Set variables
;----------------------------------------------------------------------------
(defun var_set (m_lst)
(repeat (length m_lst)
(setvar (caar m_lst) (cadar m_lst))
(setq m_lst (cdr m_lst))
)
); defun var_set ;----------------------------------------------------------------------------
; Restore variables
;----------------------------------------------------------------------------
(defun var_restore ()
(repeat (length m_lst)
(setvar (caar m_lst) (cadar m_lst))
(setq m_lst (cdr m_lst))
)
); defun var_restore ;----------------------------------------------------------------------------
; Initialize routine
;----------------------------------------------------------------------------
(defun err_init(e_lst u_enable add_fun)
(if err_alive (err_restore)) ; To avoid nested call
(setq err_alive T)
(var_save e_lst) ; Save the modes
(if u_enable (setq old_undoctl (undo_init))) ; Initialize UNDO status
(setq err_old *error* *error* err_main) ; Save the handle of *error*
(if add_fun ; Add the user cleaner
(setq *error* (append (reverse (cdr (reverse *error*)))
(list add_fun (last *error*))
); append
)
)
); defun err_init ;----------------------------------------------------------------------------
; Error routine body
;----------------------------------------------------------------------------
(defun err_main( msg / ) ; Body of error routine
(if (/= msg "Function cancelled") ;If an error (such as CTRL-C) occurs
(princ (strcat "\nError: " s)) ;while this command is active...
)
(while (not (equal (getvar "CMDNAMES") "")) (command nil)) ; Get out of any active command (if old_undoctl
(progn
(while (not (wcmatch (getvar "CMDNAMES") "*UNDO*")) ; See
(command "_.undo") ; if it's in UNOD command
)
(command "_end")
(command "_.undo" "1")
(while (not (equal (getvar "CMDNAMES") "")) (command nil))
(undo_restore) ; Restore the status of UNDO
)
) (var_restore) ; Restore the variables
(if err_old (setq *error* err_old err_old nil)) ; Restore the handle of error
(setq err_alive nil)
(princ)
); defun err_main ;----------------------------------------------------------------------------
; Restore error status
;----------------------------------------------------------------------------
(defun err_restore()
(undo_restore) ; Restore the status of UNDO
(var_restore) ; Restore the variables
(if err_old (setq *error* err_old err_old nil)) ; Restore the handle of error
(setq err_alive nil)
(princ)
); defun err_restore
发表于 2005-3-29 08:38 | 显示全部楼层
好象不全吧,没有执行命令。。。
发表于 2005-3-29 16:40 | 显示全部楼层
缺少``命令
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-19 07:01 , Processed in 0.307723 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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