加载插件提示错误: no function definition: CX-REG-YN
在论坛上下载表格删除0空格并重新编号这个插件,感觉非常好用,但加载后提示错误: no function definition: CX-REG-YN,换几个版本CAD也如此,查询翻译应该是有自定义函数不能加载。打开插件第一条命令出现了,不知如何解决,请教大佬大神帮助,谢谢!源程序如下:
(defun c:a5 ( / a a1 aa b1 box ffx h1 i kk l1 l2 la lb lbg lc ld le lk ll lsn lss lx lxx ly odlst pc sn ss sty th tw x xx y y1 y2 dxf ss2lst ssbox ebox cbox mid 3d2d CurveLength lstcj qbw mkline mktext RevmoveMt2Text explodeblk cumid)(cx-reg-yn)
(progn
(defun cumid (e) (vlax-curve-getpointatdist e (* 0.5 (vlax-curve-getdistatpoint e (vlax-curve-getendpoint e)))))
(defun explodeblk(ent)
(mapcar 'vlax-vla-object->ename (vlax-safearray->list
(vlax-variant-value
(vla-explode(vlax-ename->vla-object ent)))))
)
(defun RevmoveMt2Text (MTextString / regex s)
(setq regex(vlax-create-object "Vbscript.RegExp")) ;引用正则表达式控件
(vlax-put-property regex "IgnoreCase" 0) ;不忽略大小写
(vlax-put-property regex "Global" 1) ;匹配方式,全文字匹配
(setq s MTextString)
;替换\\字符
(vlax-put-property regex "Pattern" "\\\\\\\\")
(setq s(vlax-invoke-methodregex "Replace" s (chr 1)))
;替换\{字符
(vlax-put-property regex "Pattern" "\\\\{")
(setq s(vlax-invoke-methodregex "Replace" s (chr 2)))
;替换\}字符
(vlax-put-property regex "Pattern" "\\\\}")
(setq s(vlax-invoke-methodregex "Replace" s (chr 3)))
;删除段落缩进格式
(vlax-put-property regex "Pattern" "\\\\pi(.[^;]*);")
(setq s(vlax-invoke-methodregex "Replace" s ""))
;删除制表符格式
(vlax-put-property regex "Pattern" "\\\\pt(.[^;]*);")
(setq s(vlax-invoke-methodregex "Replace" s ""))
;删除堆迭格式
(vlax-put-property regex "Pattern" "\\\\S(.[^;]*)(\\^|#|\\\\)(.[^;]*);")
(setq s(vlax-invoke-methodregex "Replace" s ""))
;删除字体、颜色、字高、字距、倾斜、字宽、对齐格式
(vlax-put-property regex "Pattern" "(\\\\F|\\\\f|\\\\C|\\\\H|\\\\\T|\\\\Q|\\\\W|\\\\A)(.[^;]*);")
(setq s(vlax-invoke-methodregex "Replace" s ""))
;删除下划线、删除线格式
(vlax-put-property regex "Pattern" "(\\\\L|\\\\O|\\\\l|\\\\o)")
(setq s(vlax-invoke-methodregex "Replace" s ""))
;删除不间断空格格式
(vlax-put-property regex "Pattern" "\\\\~")
(setq s(vlax-invoke-methodregex "Replace" s ""))
;删除换行符格式
(vlax-put-property regex "Pattern" "\\\\P")
(setq s(vlax-invoke-methodregex "Replace" s ""))
;删除换行符格式(针对Shift+Enter格式)
(vlax-put-property regex "Pattern" "\n")
(setq s(vlax-invoke-methodregex "Replace" s ""))
;删除{}
(vlax-put-property regex "Pattern" "({|})")
(setq s(vlax-invoke-methodregex "Replace" s ""))
;替换回\\,\{,\}字符
(vlax-put-property regex "Pattern" "\\x01")
(setq s(vlax-invoke-methodregex "Replace" s "\\"))
(vlax-put-property regex "Pattern" "\\x02")
(setq s(vlax-invoke-methodregex "Replace" s "{"))
(vlax-put-property regex "Pattern" "\\x03")
(setq s(vlax-invoke-methodregex "Replace" s "}"))
(vlax-release-object regex)
s
)
(defun dxf (key ename) (cdr (assoc key (entget ename))))
(defun ss2lst ( ss / i l )
(if ss
(repeat (setq i (sslength ss))
(setq l (cons (ssname ss (setq i (1- i))) l))
)
)
)
(defun ssbox ( s / a b i m n o )
(repeat (setq i (sslength s))
(if
(and
(setq o (vlax-ename->vla-object (ssname s (setq i (1- i)))))
(vlax-method-applicable-p o 'getboundingbox)
(not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list o 'a 'b))))
)
(setq m (cons (vlax-safearray->list a) m)
n (cons (vlax-safearray->list b) n)
)
)
)
(if (and m n)
(mapcar '(lambda ( a b ) (apply 'mapcar (cons a b))) '(min max) (list m n))
)
)
(defun ebox (ent / ll ur)
(vla-getboundingbox (vlax-ename->vla-object ent) 'll 'ur)
(mapcar 'safearray-value (list ll ur))
)
(defun CurveLength (ename)
(vlax-curve-getDistAtParam
ename
(vlax-curve-getEndParam ename)
)
)
(defun lstcj ( l1 l2 )
(vl-remove-if '(lambda ( x ) (member x l2)) l1)
)
(defun qbw (lst)
(reverse (cdr (reverse lst)))
)
(defun cbox (e) (apply 'mid (ebox e)))
(defun mid (p1 p2) (mapcar (function (lambda (e1 e2) (* (+ e1 e2) 0.5))) p1 p2))
(defun 3d2d (p) (mapcar '+ p '(0 0)))
(defun ScreenWinwow(/ h c)
(setq c(getvar'viewctr)
h(*(getvar'viewsize)0.5)
h(list(*(apply'/(getvar'screensize))h)h))
(mapcar'(lambda(x)(mapcar x c h))'(- +))
)
(setq *ACAD*(vlax-get-acad-object)
*DOC* (vla-get-ActiveDocument *ACAD*)
)
(defun *error*(msg)
(mapcar 'setvar '("cmdecho" "osmode" "dimzin") odlst)
(vlax-invoke-method *DOC* 'EndUndoMark)
(princ msg)
)
(vlax-invoke-method *DOC* 'StartUndoMark)
(setq odlst (mapcar 'getvar '("cmdecho" "osmode" "dimzin")))
(mapcar 'setvar '("cmdecho" "osmode" "dimzin") '(0 0 8))
(setq lst nil
ts (princ "\n选择全部表格:")
ss (ssget '((0 . "*text,line") (8 . "表格")))
)
)
(if ss
(progn
(setq lss (ss2lst ss)
l1 (vl-remove-if-not '(lambda(x) (wcmatch (dxf 0 x) "*TEXT")) lss)
l2 (vl-remove-if-not '(lambda(x) (= "LINE" (dxf 0 x))) lss)
l2 (vl-sort l2 '(lambda (x y) (< (CurveLength x) (CurveLength y)) ) )
th (apply 'min (mapcar '(lambda(x) (dxf 40 x)) l1))
h1 (* th 0.5)
ll (ScreenWinwow)
sty (dxf 7 (car l1))
tw (dxf 41 (car l1))
)
(while l2
(setq a (car l2)
box (mapcar '3d2d (ebox a))
box (list (mapcar '- (car box) (list h1 h1)) (mapcar '+ (cadr box) (list h1 h1)))
ffx t
)
(command "zoom" "w" (car box) (cadr box) "zoom" "0.9xp")
(while (and ffx (setq sn (ssget "c" (car box) (cadr box) '((0 . "*text,line") (8 . "表格")))))
(setq b1 (mapcar '3d2d (ssbox sn))
b1 (list (mapcar '- (car b1) (list h1 h1)) (mapcar '+ (cadr b1) (list h1 h1)))
)
(command "zoom" "w" (car b1) (cadr b1) "zoom" "0.9xp")
(if (equal b1 box th)
(setq ffx nil)
(setq box b1)
)
)
(setq lsn (ss2lst sn)
l2 (lstcj l2 lsn)
)
(if (> (length lsn) 2)
(progn
(setq la (vl-remove-if-not '(lambda(x) (wcmatch (dxf 0 x) "*TEXT")) lsn)
la (vl-sort la '(lambda (x y) (< (cadr (cbox x)) (cadr (cbox y))) ) )
lb nil
)
(while la
(setq a1 (car la);
lx (vl-remove-if-not '(lambda(x) (equal (cadr (cbox x)) (cadr (cbox a1)) (* th 0.4))) la)
lx (vl-sort lx '(lambda (x y) (< (car (cbox x)) (car (cbox y))) ) )
lb (cons lx lb);
la (lstcj la lx)
)
)
(setq i 0
lb (mapcar '(lambda(x) (cons (setq i (1+ i)) x)) lb)
ly (mapcar '(lambda(x) (cons (car x) (cadr (cbox (cadr x))))) lb)
lc (mapcar '(lambda(x)
(if (equal "0" (RevmoveMt2Text (dxf 1 (last x))))
(progn
(mapcar 'entdel (cdr x))
(list (car x))
)
x
)) lb)
ld (vl-remove-if-not '(lambda(x) (= 1 (length x))) lc)
)
(if ld
(progn
(setq ld (reverse ld))
(while ld
(setq a1 (car ld)
ld (cdr ld)
)
(setq l1 (member a1 lc)
y1 (cdar (vl-remove-if-not '(lambda(x) (= (car a1) (car x))) ly))
y2 (cdar (vl-remove-if-not '(lambda(x) (= (1- (car a1)) (car x))) ly))
)
(setq le (apply 'append (mapcar 'cdr (cdr l1))))
(foreach x le
(vla-move (Vlax-Ename->Vla-Object x) (vlax-3d-point (list 0 y1)) (vlax-3d-point (list 0 y2)))
)
)
(setq ld (vl-remove-if-not '(lambda(x) (and (entget x) (wcmatch (dxf 0 x) "*TEXT"))) lsn)
lxx (vl-remove-if-not '(lambda(x) (and (entget x) (wcmatch (dxf 0 x) "LINE"))) lsn)
lbg nil
)
(setvar "clayer" "表格")
(foreach aa ld
(command "_.boundary" "a" "b" "n" sn "" "" (cbox aa) "")
(setq kk (entlast)
lk (explodeblk kk)
)
(entdel kk)
(foreach xx lk
(if (not (vl-remove-if-not '(lambda(x) (equal x (setq pc (cumid xx)) (* th 0.1))) lbg))
(setq lbg (cons pc lbg))
(entdel xx)
)
)
)
(mapcar 'entdel lxx)
(setq ld (vl-remove-if-not '(lambda(x) (> (length x) 1)) lc))
(setq ld (mapcar 'cadr (cdr ld)))
(setq i 0)
(foreach aa ld
(Vlax-Put-Property (Vlax-Ename->Vla-Object aa) 'TextString (itoa (setq i (1+ i))))
)
)
)
)
)
);
(command "zoom" "w" (car ll) (cadr ll))
)
(princ "\n表格图层没对象被选择到:")
)
(mapcar 'setvar '("cmdecho" "osmode" "dimzin") odlst)
(vlax-invoke-method *DOC* 'EndUndoMark)
)
jhzxj 发表于 2021-11-26 19:33
大神,怎么删除?可否指点下,我对lisp不懂,请指教下,谢谢!
就是按 “htlaser” 说的,在原程序中把那一句(cx-reg-yn)查找,删掉就可以了,已经试过了,删了就可以了。 panliang9 发表于 2021-11-23 14:31
确实是,删了以后,似乎就行了。可以处理图层名为表格的表格对象。格式须按原贴的表格。
大神,怎么删除?可否指点下,我对lisp不懂,请指教下,谢谢! panliang9 发表于 2021-11-29 09:10
就是按 “htlaser” 说的,在原程序中把那一句(cx-reg-yn)查找,删掉就可以了,已经试过了,删了就可以了 ...
谢谢指点,非常感谢,我试试。 把这个删除 (cx-reg-yn) 试试 提示错误: no function definition: CX-REG-YN,提示这个是缺少了 CX-REG-YN这个函数 一般这个是为函数
这个看意思应该是注册类的函数 烟盒迷唇 发表于 2021-11-23 08:56
这个看意思应该是注册类的函数
能否修改下? 论坛原贴发一下链接,大家一起看下。 jhzxj 发表于 2021-11-23 09:23
能否修改下?
注释掉就得了,不影响程序使用。 panliang9 发表于 2021-11-23 09:23
论坛原贴发一下链接,大家一起看下。
原帖子http://bbs.mjtd.com/forum.php?mod=viewthread&tid=182525&highlight=%D6%D8%D0%C2 htlaser 发表于 2021-11-22 09:26
把这个删除 (cx-reg-yn)试试
确实是,删了以后,似乎就行了。可以处理图层名为表格的表格对象。格式须按原贴的表格。 看起来是用了他自己的函数库吧
页:
[1]
2