3dwannab 发表于 2022-7-5 15:06:40

LISP fn返回外部参照计数a

大家好,
 
我有一个脚本,从这里我已经调整,以获得计数。
 
(defun C:XREFCNT (/ i x)
(setq i 0)
(vlax-for x
        (vla-get-blocks
                (vla-get-ActiveDocument (vlax-get-acad-object))
                )
        (if (eq (vla-get-IsXref x) :vlax-true)
                (setq i (1+ i))
                )
        )
i
)
 
XREFCNT返回命令行中的数字。
 
然后我该如何发出警报,下面的代码不起作用。It错误:
错误:错误的参数类型:fixnump:#
 
(if XREFCNT > 0)
(alert
(strcat "Number of External Reference Drawings = " (itoa (strcat XREFCNT)))
)

Aftertouch 发表于 2022-7-5 15:30:34

命令XREFCNT定义为“#”。
 
更改此项:
 

(itoa (strcat XREFCNT))

 
收件人:

(itoa (strcat (XREFCNT)))

 
和改变
 

(defun C:XREFCNT (/ i x)

 
收件人:
 

(defun XREFCNT (/ i x)

hanhphuc 发表于 2022-7-5 15:37:24

   (if (> (setq c (XREFCNT)) 0)
    (alert (strcat "Number of External Reference Drawings = " (itoa c)))
    )

3dwannab 发表于 2022-7-5 15:44:43

谢谢你们俩。
 
这是工作代码。
(defun XREFCNT (/ i x)
(setq i 0)
(vlax-for x
        (vla-get-blocks
                (vla-get-ActiveDocument (vlax-get-acad-object))
                )
        (if (eq (vla-get-IsXref x) :vlax-true)
                (setq i (1+ i))
                )
        )
i
)
; SETS XREF PATHS TO "RELATIVE" IF IN DRAWING
(if (> (setq c (XREFCNT)) 0)
        ; (alert (strcat "Number of External Reference Drawings = " (itoa c)))
        (command "-XREF" "T" "*" "R")
        )

BIGAL 发表于 2022-7-5 16:06:06

可以使用C:xrefcnt,但defun调用必须匹配(C:xrefcnt)
 
是否有理由不在现场?

(defun c:XREFCNT2 (/ i x)
(setq i 0)
        (vlax-for x
        (vla-get-blocks
                (vla-get-ActiveDocument (vlax-get-acad-object))
                )
        (if (eq (vla-get-IsXref x) :vlax-true)
                (setq i (1+ i))
                )
)
(if (> i 0)
        (alert (strcat "Number of External Reference Drawings = " (rtos i 2 0)))
        (alert "No Xrefs")
       )
)
(c:XREFCNT2)

3dwannab 发表于 2022-7-5 16:08:26

 
因为我在下面使用了redir命令。我在启动脚本的其他地方调用它。
 
(if
(vl-string-search "company_name_here" (strcat(getvar 'dwgprefix)))
(progn
        (if (> (setq c (XREFCNT)) 0)
                (Command ".script" "XRef_company_name_here_Paths_Fix.scr")
                )
        (setq StyleSheet "company_name_here.ctb")
        )
)
页: [1]
查看完整版本: LISP fn返回外部参照计数a