乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 68|回复: 10

[编程交流] autocad中的字数计算

[复制链接]

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 20:16:17 | 显示全部楼层 |阅读模式
大家好!
我知道这个问题在这里被提过不止一次。然而,到目前为止,我还没有找到我需要的东西。
我是一名翻译,最近主要处理autocad绘图。我不得不说,获得正确的字数是相当具有挑战性的。我在这个论坛上尝试了几个Lisp,但它们都有一个严重的缺点,使得它们实际上毫无用处,即,除了我需要的东西之外,它们还提取了大量不受欢迎的垃圾(垃圾我指的是“\pxql”等东西,它们似乎经常弹出,并将我的统计数据膨胀到超出合理的程度)。Lisp程序张贴在这里http://www.jefferypsanders.com/autolisp_WORDS.html似乎对此有某种过滤器,在它的帮助下,我想,有可能从图纸中提取相对“精简”的文本。然而,它的缺点是一个单词只提取一次,即使它在图形中重复了一百次。这也太糟糕了,因为我需要把重复次数也包括在我的统计数据中。
你们能提出一个解决方案吗?
回复

使用道具 举报

10

主题

8258

帖子

8335

银币

初来乍到

Rank: 1

铜币
31
发表于 2022-7-5 20:23:56 | 显示全部楼层
你能用QSELECT吗?
 
计数中是否包含属性?
 
你看到这条线了吗?
 
http://www.cadtutor.net/forum/showthread.php?79-导出文本
 
另一种选择是购买DotSoft的ToolPac。“注释工具”下有一个称为“计数”的功能。描述:统计注释对象选择集中文本字符串或文字的出现次数。
回复

使用道具 举报

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 20:31:57 | 显示全部楼层
评论
 
 
1) 坦率地说,不知道该如何使用这个东西;
2) 不,属性需要省略;
3) 就像我说的那样,Lisp程序提取了很多我并不真正需要的东西。举个例子:
 
 
\pxql;SCMI_云
\pxql;SCMI_专栏
\pxql;SCMI_DETALLE公司
 
 
\pxqc;A1
\pxqc;A2
\pxqc;A3
\pxqc;A4
 
 
理想的解决方案是对jefferypsanders上的lisp进行一些修改。com,一个可以过滤掉所有垃圾并包含重复内容的网站。但我不知道是否存在这样的事情。
回复

使用道具 举报

10

主题

8258

帖子

8335

银币

初来乍到

Rank: 1

铜币
31
发表于 2022-7-5 20:38:21 | 显示全部楼层
QSELECT>Text>Layer。
 
你有没有看我贴的链接?
回复

使用道具 举报

39

主题

180

帖子

141

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
195
发表于 2022-7-5 20:42:12 | 显示全部楼层
这里有一个Lisp例程,你可以试试。。。
 
  1. ; TXTCNT.lsp - Count how many times each text entity appears.
  2. ; Display the results sorted in a dialog box.
  3. ; BY jeffery p sanders
  4. (defun C:TXTCNT ()
  5.                                        ;define a sort routine - Usage: (srt list) - Let's not go into this yet! It works.
  6. (defun srt (alist / n)
  7.    (setq lcup nil
  8.          rcup nil
  9.    )
  10.    (defun cts (a b)
  11.      (cond ((> a b) t)
  12.            ((= a b) t)
  13.            (t nil)
  14.      )
  15.    )
  16.    (foreach n alist
  17.      (while (and rcup (cts n (car rcup)))
  18.        (setq lcup (cons (car rcup) lcup)
  19.              rcup (cdr rcup)
  20.        )
  21.      )
  22.      (while (and lcup (cts (car lcup) n))
  23.        (setq rcup (cons (car lcup) rcup)
  24.              lcup (cdr lcup)
  25.        )
  26.      )
  27.      (setq rcup (cons n rcup))
  28.    )
  29.    (append (reverse lcup) rcup)
  30. )
  31.                                        ;turn the command echo off
  32. (setvar "cmdecho" 0)
  33.                                        ;setup a variable to hold the data
  34. (setq datalist (list))
  35.                                        ;select objects
  36. (if (setq eset (ssget))
  37.    (progn
  38.                                        ;set a counter to the first item in the selection set
  39.      (setq cntr 0)
  40.                                        ;loop through each selected entity
  41.      (while (< cntr (sslength eset))
  42.                                        ;grab the entity's name
  43.        (setq en (ssname eset cntr))
  44.                                        ;grab the DXF group codes of the entity
  45.        (setq enlist (entget en))
  46.                                        ;ignore the entity if it is not a TEXT entity
  47.        (if (= "TEXT" (cdr (assoc 0 enlist)))
  48.          (progn
  49.                                        ;get the text value from the DXF Group Code
  50.            (setq str (cdr (assoc 1 enlist)))
  51.                                        ;setup a variable to check if the entity exist in the datalist list
  52.            (setq existing 0)
  53.                                        ;loop through the datalist to find out if it is a new entity that needs
  54.                                        ;to be added to the list or if it already exist and it's counter needs
  55.                                        ;to be incremented
  56.            (foreach a datalist
  57.              (if (= (car a) str)
  58.                (setq existing 1)
  59.              )
  60.            )
  61.                                        ;if the entity is new then
  62.            (if (= existing 0)
  63.                                        ;do this - Add the item to the datalist along with a counter that starts at 1
  64.              (setq datalist (append datalist (list (cons str 1))))
  65.                                        ;else it's cntr needs to be incremented
  66.              (setq datalist
  67.                     (subst
  68.                       (cons str (+ 1 (cdr (assoc str datalist))))
  69.                       (assoc str datalist)
  70.                       datalist
  71.                     )
  72.              )
  73.            )
  74.          )
  75.        )
  76.                                        ;increment the entity counter
  77.        (setq cntr (+ cntr 1))
  78.      )
  79.    )
  80. )
  81.                                        ;setup a variable to hold the data again, this time in a different fashion
  82. (setq newList (list))
  83.                                        ;rearrange the list
  84. (foreach a datalist
  85.    (setq newList
  86.           (append
  87.             newList
  88.             (list
  89.               (strcat
  90.                 (substr
  91.                   (strcat
  92.                     (car a)
  93.                     " . . . . . . . . . . . . . . . . . . . . . . . . . . "
  94.                   )
  95.                   1
  96.                   50
  97.                 )
  98.                 " - "
  99.                 (itoa (cdr a))
  100.               )
  101.             )
  102.           )
  103.    )
  104. )
  105.                                        ;sort the list
  106. (setq newList (srt newList))
  107.                                        ;put up the dialog box
  108. (setq dcl_id (load_dialog "TXTCNT.dcl"))
  109.                                        ;see if it is already loaded
  110. (if (not (new_dialog "TXTCNT" dcl_id))
  111.    (exit)
  112. )
  113.                                        ;add the data to the list in the dialog box
  114. (start_list "datalist")
  115. (mapcar 'add_list newList)
  116. (end_list)
  117.                                        ;if an action event occurs, do this function
  118. (action_tile "cancel" "(setq ddiag 1)(done_dialog)")
  119. (action_tile "insert" "(setq ddiag 2)(done_dialog)")
  120.                                        ;display the dialog box
  121. (start_dialog)
  122.                                        ;if the cancel button was pressed - display message
  123. (if (= ddiag 1)
  124.    (princ "\n \n ...TXTCNT Cancelled. \n ")
  125. )
  126. (if(= ddiag 2)
  127.    (progn
  128.      (setq pt(getpoint "\n Insertion Point: "))
  129.      (foreach a newList
  130.           (command "-style" "ARIAL" "ARIAL" "" "" "" "" "")
  131.           (command "text" pt "" "" a)
  132.        (setq pt(polar pt (* pi 1.5) (* (getvar "textsize") 1.25)))
  133.      )
  134.    )
  135. )
  136.                                        ;unload the dialog box
  137. (unload_dialog dcl_id)
  138.                                        ;turn the command echo back on
  139. (setvar "cmdecho" 1)
  140.                                        ;supress the last echo
  141. (princ)
  142. )

 
TXTCNT。DCL
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 20:47:47 | 显示全部楼层
 
FWIW,您所说的“垃圾”是文本内容中存在的多行文字格式代码,当通过多行文字编辑器应用格式替代时会出现这些代码。
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 20:52:23 | 显示全部楼层
另一种稍有不同的方法是选择所有文本,包括多行文字,然后分解。这将去除多行文字控件,进行字数计算,但不保存或几个撤消操作。
回复

使用道具 举报

39

主题

180

帖子

141

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
195
发表于 2022-7-5 21:00:41 | 显示全部楼层
这样做唯一的坏处是,如果不需要的话,你必须删除所有的数字。
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 21:06:37 | 显示全部楼层
BrainTFC公司
 
此功能可以缩短,如下所示。
 
  1. (defun cts  (a b)
  2. (cond ((> a b) t)
  3.        ((= a b) t)
  4.        (t nil)
  5.        )
  6. )
  1. (defun cts  (a b)
  2. (or (> a b)
  3.      (= a b)
  4.      )
  5. )
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 21:13:22 | 显示全部楼层
 
或者只是
  1. (defun cts ( a b ) (>= a b))
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-11 09:09 , Processed in 0.372238 second(s), 72 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表