乐筑天下

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

[编程交流] 使用文字转换线型

[复制链接]

15

主题

71

帖子

56

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-6 11:47:18 | 显示全部楼层 |阅读模式
我需要帮助。我正在REVIT 2010中进行一个项目,该程序无法识别包含字母的线型。因此,当我导入AutoCAD图形时,它们都是实线。
 
我要找的是一个lisp(适用于AutoCAD),它可以识别选定的线条线型,然后创建一条小线,然后创建一段文字,并在线条长度上重复此操作。如果有人知道这是否可能,请告诉我。
 
目前,我只是手动操作,这非常耗时。
回复

使用道具 举报

8

主题

1133

帖子

1164

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 11:59:01 | 显示全部楼层
也许你会对此感兴趣。
 
我将ExpressTools文本分解更改为分解行(lnexp.lsp)。正如您在图片中通过夹点看到的那样,底线是一条线,而顶线分解为单独的线。文本不再是文本,而是多段线。
 
  1. ;;
  2. ;;;
  3. ;;;    By Dominic Panholzer
  4. ;;;
  5. ;;;    TXTEXP.LSP
  6. ;;;    Copyright © 1999 by Autodesk, Inc.
  7. ;;;
  8. ;;;    Your use of this software is governed by the terms and conditions of the
  9. ;;;    License Agreement you accepted prior to installation of this software.
  10. ;;;    Please note that pursuant to the License Agreement for this software,
  11. ;;;    "[c]opying of this computer program or its documentation except as
  12. ;;;    permitted by this License is copyright infringement under the laws of
  13. ;;;    your country.  If you copy this computer program without permission of
  14. ;;;    Autodesk, you are violating the law."
  15. ;;;
  16. ;;;    AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
  17. ;;;    AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
  18. ;;;    MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC.
  19. ;;;    DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
  20. ;;;    UNINTERRUPTED OR ERROR FREE.
  21. ;;;
  22. ;;;    Use, duplication, or disclosure by the U.S. Government is subject to
  23. ;;;    restrictions set forth in FAR 52.227-19 (Commercial Computer
  24. ;;;    Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
  25. ;;;    (Rights in Technical Data and Computer Software), as applicable.
  26. ;;;
  27. ;;;  ----------------------------------------------------------------
  28. ;;;
  29. ;;;  External Functions:
  30. ;;;
  31. ;;;     ACET-ERROR-INIT           --> ACETUTIL.FAS   Intializes bonus error routine
  32. ;;;     ACET-ERROR-RESTORE        --> ACETUTIL.FAS   Restores old error routine
  33. ;;;     ACET-GEOM-ZOOM-FOR-SELECT --> ACETUTIL.FAS   Zoom boundry to include points given
  34. ;;;     ACET-LAYER-LOCKED         --> ACETUTIL.FAS   Checks to see if layer is locked
  35. ;;;     ACET-GEOM-PIXEL-UNIT      --> ACETUTIL.FAS   Size of pixel in drawing units
  36. ;;;     ACET-GEOM-TEXTBOX         --> ACETUTIL.FAS   Returns the textbox for any text
  37. ;;;     ACET-GEOM-MIDPOINT        --> ACETUTIL.FAS   Returns midpoint between two points
  38. ;;;     ACET-GEOM-VIEW-POINTS     --> ACETUTIL.FAS   Returns corner points of screen or viewport
  39. ;;;     ACET-STR-FORMAT           --> ACETUTIL.ARX   String builder
  40. ;;;     ACET-WMFIN                --> ACETUTIL.FAS   Brings in WMF file
  41. ;;;
  42. ;   Amended by eldon to explode a line January 2009
  43. (defun c:lnexp (/ grplst getgname blknm FLTR GLST GDICT SS VIEW UPLFT TMPFIL TBX
  44.                   TMPFIL CNT PT1 PT2 ENT TXT TXTYP PTLST ZM LOCKED GNAM vpna vplocked)
  45. (acet-error-init
  46.        (list
  47.         (list   "cmdecho" 0
  48.                 "highlight" 1
  49.                 "osmode" 0
  50.                 "Mirrtext" 1
  51.                 "limcheck" 0
  52.         )
  53.         T
  54.        )
  55. )
  56. ; --------------------- GROUP LIST FUNCTION ----------------------
  57. ;   This function will return a list of all the group names in the
  58. ;   drawing and their entity names in the form:
  59. ;   ((<ename1> . <name1>) ... (<enamex> . <namex>))
  60. ; ----------------------------------------------------------------
  61. (defun acet-txtexp-grplst (/ GRP ITM NAM ENT GLST)
  62.    (setq GRP  (dictsearch (namedobjdict) "ACAD_GROUP"))
  63.    (while (setq ITM (car GRP))       ; While edata item is available
  64.      (if (= (car ITM) 3)             ; if the item is a group name
  65.        (setq NAM (cdr ITM)           ; get the name
  66.              GRP (cdr GRP)           ; shorten the edata
  67.              ITM (car GRP)           ; get the next item
  68.              ENT (cdr ITM)           ; which is the ename
  69.              GRP (cdr GRP)           ; shorten the edata
  70.              GLST                    ; store the ename and name
  71.                  (if GLST
  72.                    (append GLST (list (cons ENT NAM)))
  73.                    (list (cons ENT NAM))
  74.                  )
  75.        )
  76.        (setq GRP (cdr GRP))          ; else shorten the edata
  77.      )
  78.    )
  79.    GLST                              ; return the list
  80. )
  81. ; ------------------- GET GROUP NAME FUNCTION --------------------
  82. ;   This function returns a list of all the group names in GLST
  83. ;   where ENT is a member. The list has the same form as GLST
  84. ; ----------------------------------------------------------------
  85. (defun acet-txtexp-getgname (ENT GLST / GRP GDATA NAM NLST)
  86.    (if (and GLST (listp GLST))
  87.      (progn
  88.        (foreach GRP GLST
  89.          (setq GDATA (entget (car GRP)))
  90.          (foreach ITM GDATA                   ; step through the edata
  91.            (if (and
  92.                  (= (car ITM) 340)            ; if the item is a entity name
  93.                  (eq (setq NAM (cdr ITM)) ENT) ; and the ename being looked for
  94.                )
  95.              (setq NLST                       ; store the ename and name
  96.                      (if NLST
  97.                        (append NLST (list (cons (car GRP) (cdr GRP))))
  98.                        (list (cons (car GRP) (cdr GRP)))
  99.                      )
  100.              )
  101.            )
  102.          )
  103.        )
  104.      )
  105.    )
  106.    NLST
  107. )
  108. ; ----------------------------------------------------------------
  109. ;                          MAIN PROGRAM
  110. ; ----------------------------------------------------------------
  111. (if (and                                                ; Are we in plan view?
  112.        (equal (car (getvar "viewdir")) 0 0.00001)
  113.        (equal (cadr (getvar "viewdir")) 0 0.00001)
  114.        (> (caddr (getvar "viewdir")) 0)
  115.      )
  116.    (progn
  117.      (prompt "\nSelect line to be EXPLODED: ")
  118.      (Setq FLTR    '((-4 . "<AND")
  119.                        ;(-4 . "<OR")                      ; filter for mtext and text
  120.                        ;  (0 . "MTEXT")
  121.                        ;  (0 . "TEXT")
  122.                        ;(-4 . "OR>")
  123.                        (-4 . "<NOT")
  124.                          (102 . "{ACAD_REACTORS")        ; and not leader text
  125.                        (-4 . "NOT>")
  126.                      (-4 . "AND>")
  127.                     )
  128.            GLST     (acet-txtexp-grplst)                             ; Get all the groups in drawing
  129.            GDICT    (if GLST
  130.                       (dictsearch (namedobjdict) "ACAD_GROUP")
  131.                     )
  132.            SS       (ssget  FLTR)
  133.            CNT      0
  134.      )
  135.      ;; filter out the locked layers
  136.      (if SS
  137.        (setq SS (car (bns_ss_mod SS 1 T)))
  138.      ) ;if
  139.      ;; if we have anything left
  140.      (if SS
  141.        (progn
  142.          (setq CNT 0)                                 ; Reset counter
  143.          (while (setq ENT (ssname SS CNT))            ; step through each object in set
  144.            (and
  145.              GLST                                     ; if groups are present in the drawing
  146.              (setq GNAM (acet-txtexp-getgname ENT GLST))          ; and the text item is in one or more
  147.              (foreach GRP GNAM                        ; step through those groups
  148.                (command "_.-group" "_r"               ; and remove the text item
  149.                  (cdr GRP) ENT ""
  150.                )
  151.              )
  152.            )
  153.            (setq TBX (acet-geom-textbox (entget ENT) 0))   ; get textbox points
  154.            (setq TBX (mapcar '(lambda (x)
  155.                                 (trans x 1 0)         ; convert the points to WCS
  156.                               )
  157.                        TBX
  158.                      )
  159.            )
  160.            (setq PTLST (append PTLST TBX))            ; Build list of bounding box
  161.                                                       ; points for text items selected
  162.            (setq CNT (1+ CNT))                        ; get the next text item
  163.          ); while
  164.          (setq PTLST (mapcar '(lambda (x)
  165.                                 (trans x 0 1)         ; convert all the points
  166.                               )                       ; to the current ucs
  167.                      PTLST
  168.                    )
  169.          )
  170.          (if (setq ZM (acet-geom-zoom-for-select PTLST))          ; If current view does not contain
  171.            (progn                                     ; all bounding box points
  172.              (setq ZM
  173.                (list
  174.                  (list (- (caar ZM) (acet-geom-pixel-unit))     ; increase zoom area by
  175.                        (- (cadar ZM) (acet-geom-pixel-unit))    ; one pixel width to
  176.                        (caddar ZM)                    ; sure nothing will be lost
  177.                  )
  178.                  (list (+ (caadr ZM) (acet-geom-pixel-unit))
  179.                        (+ (cadadr ZM) (acet-geom-pixel-unit))
  180.                        (caddr (cadr zm))
  181.                  )
  182.                )
  183.              )
  184.              (if (setq vpna (acet-currentviewport-ename))
  185.                  (setq vplocked (acet-viewport-lock-set vpna nil))
  186.              );if
  187.              (command "_.zoom" "_w" (car ZM) (cadr ZM))  ; zoom to include text objects
  188.            )
  189.          )
  190.          (setq VIEW     (acet-geom-view-points)
  191.                TMPFIL   (strcat (getvar "tempprefix") "txtexp.wmf")
  192.                PT1      (acet-geom-midpoint (car view) (cadr view))
  193.                PT2      (list (car PT1) (cadadr VIEW))
  194.          )
  195.          (if (acet-layer-locked (getvar "clayer"))       ; if current layer is locked
  196.            (progn
  197.              (command "_.layer" "_unl" (getvar "clayer") "")  ; unlock it
  198.              (setq LOCKED T)
  199.            )
  200.          )
  201.          (command "_.mirror" SS "" PT1 PT2 "_y"
  202.                   "_.WMFOUT" TMPFIL SS "")
  203.          (if (findfile tmpfil)                           ; Does WMF file exist?
  204.            (progn
  205.              (command "_.ERASE" SS "")                   ; erase the orignal text
  206.              (setq ss (acet-wmfin TMPFIL))               ; insert the WMF file
  207.              (command "_.mirror" ss "" PT1 PT2 "_y")
  208.            ) ;progn
  209.          ) ;if
  210.          (if LOCKED
  211.            (command "_.layer" "_lock" (getvar "clayer") "") ; relock if needed
  212.          ) ;if
  213.          (if ZM (command "_.zoom" "_p"))              ; Restore original view if needed
  214.          (if vplocked
  215.              (acet-viewport-lock-set vpna T) ;re-lock the viewport if needed.
  216.          );if
  217.          (prompt (acet-str-format "\n%1 text object(s) have been exploded to lines."  CNT))
  218.          (prompt "\nThe line objects have been placed on layer 0.")
  219.        )
  220.      )
  221.    )
  222.    (prompt "\nView needs to be in plan (0 0 1).")
  223. );if equal
  224. (acet-error-restore)                                  ; Retsore values
  225. (princ)
  226. )
  227. (princ)

124723nlm3q6ln1hq0lsp0.jpg
回复

使用道具 举报

15

主题

71

帖子

56

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-6 12:02:30 | 显示全部楼层
我可以更改defun的名称以不覆盖快速工具lisp吗?
 
我只是不想卷入任何关于工作界限的问题。
回复

使用道具 举报

8

主题

1133

帖子

1164

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 12:16:49 | 显示全部楼层
如果您向下滚动到我添加了关于更改它的注释的地方,我调用了函数“lnexp”(行分解),这样它就不会覆盖原始的txtexp。
回复

使用道具 举报

15

主题

71

帖子

56

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-6 12:19:15 | 显示全部楼层
我注意到你把它改成了lnexp。我试试看,谢谢。
回复

使用道具 举报

8

主题

1133

帖子

1164

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 12:27:21 | 显示全部楼层
一个小小的警告,我发现对于长线,缩放并不完美,所以要准备好调整每条端点,以获得相同的整体尺寸。
回复

使用道具 举报

15

主题

71

帖子

56

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-6 12:36:41 | 显示全部楼层
它似乎从原始位置删除了这条线,它们的字母在X轴和Y轴上镜像显示,而不是0,0。
回复

使用道具 举报

15

主题

71

帖子

56

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-6 12:41:17 | 显示全部楼层
我正在绘制的图纸是现场平面图,因此这些单元被设置为英尺。当我把它改为英寸时,线条现在显示在开始的地方,但字母仍然颠倒。
回复

使用道具 举报

8

主题

1133

帖子

1164

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 12:52:04 | 显示全部楼层
它看起来并不完美,我确实不得不把这句话的内容镜像出来。它还将所有内容更改为第0层,使其线宽为零,仅举几例,但它确实分解了线。
 
它的工作原理是从图形中导出WMF图像,然后重新导入图像。
 
也许你需要做太多的编辑才能发挥作用。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-5 11:03 , Processed in 0.362472 second(s), 72 queries .

© 2020-2025 乐筑天下

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