autocad中的字数计算
大家好!我知道这个问题在这里被提过不止一次。然而,到目前为止,我还没有找到我需要的东西。
我是一名翻译,最近主要处理autocad绘图。我不得不说,获得正确的字数是相当具有挑战性的。我在这个论坛上尝试了几个Lisp,但它们都有一个严重的缺点,使得它们实际上毫无用处,即,除了我需要的东西之外,它们还提取了大量不受欢迎的垃圾(垃圾我指的是“\pxql”等东西,它们似乎经常弹出,并将我的统计数据膨胀到超出合理的程度)。Lisp程序张贴在这里http://www.jefferypsanders.com/autolisp_WORDS.html似乎对此有某种过滤器,在它的帮助下,我想,有可能从图纸中提取相对“精简”的文本。然而,它的缺点是一个单词只提取一次,即使它在图形中重复了一百次。这也太糟糕了,因为我需要把重复次数也包括在我的统计数据中。
你们能提出一个解决方案吗? 你能用QSELECT吗?
计数中是否包含属性?
你看到这条线了吗?
http://www.cadtutor.net/forum/showthread.php?79-导出文本
另一种选择是购买DotSoft的ToolPac。“注释工具”下有一个称为“计数”的功能。描述:统计注释对象选择集中文本字符串或文字的出现次数。 评论
1) 坦率地说,不知道该如何使用这个东西;
2) 不,属性需要省略;
3) 就像我说的那样,Lisp程序提取了很多我并不真正需要的东西。举个例子:
\pxql;SCMI_云
\pxql;SCMI_专栏
\pxql;SCMI_DETALLE公司
\pxqc;A1
\pxqc;A2
\pxqc;A3
\pxqc;A4
理想的解决方案是对jefferypsanders上的lisp进行一些修改。com,一个可以过滤掉所有垃圾并包含重复内容的网站。但我不知道是否存在这样的事情。 QSELECT>Text>Layer。
你有没有看我贴的链接? 这里有一个Lisp例程,你可以试试。。。
; TXTCNT.lsp - Count how many times each text entity appears.
; Display the results sorted in a dialog box.
; BY jeffery p sanders
(defun C:TXTCNT ()
;define a sort routine - Usage: (srt list) - Let's not go into this yet! It works.
(defun srt (alist / n)
(setq lcup nil
rcup nil
)
(defun cts (a b)
(cond ((> a b) t)
((= a b) t)
(t nil)
)
)
(foreach n alist
(while (and rcup (cts n (car rcup)))
(setq lcup (cons (car rcup) lcup)
rcup (cdr rcup)
)
)
(while (and lcup (cts (car lcup) n))
(setq rcup (cons (car lcup) rcup)
lcup (cdr lcup)
)
)
(setq rcup (cons n rcup))
)
(append (reverse lcup) rcup)
)
;turn the command echo off
(setvar "cmdecho" 0)
;setup a variable to hold the data
(setq datalist (list))
;select objects
(if (setq eset (ssget))
(progn
;set a counter to the first item in the selection set
(setq cntr 0)
;loop through each selected entity
(while (< cntr (sslength eset))
;grab the entity's name
(setq en (ssname eset cntr))
;grab the DXF group codes of the entity
(setq enlist (entget en))
;ignore the entity if it is not a TEXT entity
(if (= "TEXT" (cdr (assoc 0 enlist)))
(progn
;get the text value from the DXF Group Code
(setq str (cdr (assoc 1 enlist)))
;setup a variable to check if the entity exist in the datalist list
(setq existing 0)
;loop through the datalist to find out if it is a new entity that needs
;to be added to the list or if it already exist and it's counter needs
;to be incremented
(foreach a datalist
(if (= (car a) str)
(setq existing 1)
)
)
;if the entity is new then
(if (= existing 0)
;do this - Add the item to the datalist along with a counter that starts at 1
(setq datalist (append datalist (list (cons str 1))))
;else it's cntr needs to be incremented
(setq datalist
(subst
(cons str (+ 1 (cdr (assoc str datalist))))
(assoc str datalist)
datalist
)
)
)
)
)
;increment the entity counter
(setq cntr (+ cntr 1))
)
)
)
;setup a variable to hold the data again, this time in a different fashion
(setq newList (list))
;rearrange the list
(foreach a datalist
(setq newList
(append
newList
(list
(strcat
(substr
(strcat
(car a)
" . . . . . . . . . . . . . . . . . . . . . . . . . . "
)
1
50
)
" - "
(itoa (cdr a))
)
)
)
)
)
;sort the list
(setq newList (srt newList))
;put up the dialog box
(setq dcl_id (load_dialog "TXTCNT.dcl"))
;see if it is already loaded
(if (not (new_dialog "TXTCNT" dcl_id))
(exit)
)
;add the data to the list in the dialog box
(start_list "datalist")
(mapcar 'add_list newList)
(end_list)
;if an action event occurs, do this function
(action_tile "cancel" "(setq ddiag 1)(done_dialog)")
(action_tile "insert" "(setq ddiag 2)(done_dialog)")
;display the dialog box
(start_dialog)
;if the cancel button was pressed - display message
(if (= ddiag 1)
(princ "\n \n ...TXTCNT Cancelled. \n ")
)
(if(= ddiag 2)
(progn
(setq pt(getpoint "\n Insertion Point: "))
(foreach a newList
(command "-style" "ARIAL" "ARIAL" "" "" "" "" "")
(command "text" pt "" "" a)
(setq pt(polar pt (* pi 1.5) (* (getvar "textsize") 1.25)))
)
)
)
;unload the dialog box
(unload_dialog dcl_id)
;turn the command echo back on
(setvar "cmdecho" 1)
;supress the last echo
(princ)
)
TXTCNT。DCL
FWIW,您所说的“垃圾”是文本内容中存在的多行文字格式代码,当通过多行文字编辑器应用格式替代时会出现这些代码。 另一种稍有不同的方法是选择所有文本,包括多行文字,然后分解。这将去除多行文字控件,进行字数计算,但不保存或几个撤消操作。 这样做唯一的坏处是,如果不需要的话,你必须删除所有的数字。 BrainTFC公司
此功能可以缩短,如下所示。
(defun cts(a b)
(cond ((> a b) t)
((= a b) t)
(t nil)
)
)
(defun cts(a b)
(or (> a b)
(= a b)
)
)
或者只是
(defun cts ( a b ) (>= a b))
页:
[1]
2