乐筑天下

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

[编程交流] 帮助编辑LISP

[复制链接]

14

主题

78

帖子

64

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 12:05:01 | 显示全部楼层 |阅读模式
我遇到了一个LISP,它将线型分解为它们的组成线,我确实偶尔可以使用它。唯一的问题是,当LISP分解线型时,它会将所有内容放入第0层。有没有人能帮我编辑这个LISP,使线条理想地停留在它们已经在的层中,或者至少让我为它们选择一个不同的层?谢谢
 
  1. ;;;        EXPLODES LINETYPES INTO INDIVIDUAL COMPONENTS
  2. ;;;
  3. ;;;    By Dominic Panholzer
  4. ;;;
  5. ;;;    Modified original TXTEXP.LSP from Express Tools
  6. ;;;    Copyright © 1999 by Autodesk, Inc.
  7. ;;     LINEXP.LSP modifications by XANADU
  8. ;;;
  9. ;;;    Your use of this software is governed by the terms and conditions of the
  10. ;;;    License Agreement you accepted prior to installation of this software.
  11. ;;;    Please note that pursuant to the License Agreement for this software,
  12. ;;;    "[c]opying of this computer program or its documentation except as
  13. ;;;    permitted by this License is copyright infringement under the laws of
  14. ;;;    your country.  If you copy this computer program without permission of
  15. ;;;    Autodesk, you are violating the law."
  16. ;;;
  17. ;;;    AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
  18. ;;;    AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
  19. ;;;    MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC.
  20. ;;;    DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
  21. ;;;    UNINTERRUPTED OR ERROR FREE.
  22. ;;;
  23. ;;;    Use, duplication, or disclosure by the U.S. Government is subject to
  24. ;;;    restrictions set forth in FAR 52.227-19 (Commercial Computer
  25. ;;;    Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
  26. ;;;    (Rights in Technical Data and Computer Software), as applicable.
  27. ;;;
  28. ;;;  ----------------------------------------------------------------
  29. ;;;
  30. ;;;  External Functions:
  31. ;;;
  32. ;;;     ACET-ERROR-INIT           --> ACETUTIL.FAS   Intializes bonus error routine
  33. ;;;     ACET-ERROR-RESTORE        --> ACETUTIL.FAS   Restores old error routine
  34. ;;;     ACET-GEOM-ZOOM-FOR-SELECT --> ACETUTIL.FAS   Zoom boundry to include points given
  35. ;;;     ACET-LAYER-LOCKED         --> ACETUTIL.FAS   Checks to see if layer is locked
  36. ;;;     ACET-GEOM-PIXEL-UNIT      --> ACETUTIL.FAS   Size of pixel in drawing units
  37. ;;;     ACET-GEOM-TEXTBOX         --> ACETUTIL.FAS   Returns the textbox for any text
  38. ;;;     ACET-GEOM-MIDPOINT        --> ACETUTIL.FAS   Returns midpoint between two points
  39. ;;;     ACET-GEOM-VIEW-POINTS     --> ACETUTIL.FAS   Returns corner points of screen or viewport
  40. ;;;     ACET-STR-FORMAT           --> ACETUTIL.ARX   String builder
  41. ;;;     ACET-WMFIN                --> ACETUTIL.FAS   Brings in WMF file
  42. ;;;
  43. (defun c:linexp (/ 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 lines 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 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)
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-6 12:18:05 | 显示全部楼层
  1. ;;;    Your use of this software is governed by the terms and conditions of the
  2. ;;;    License Agreement you accepted prior to installation of this software.
  3. ;;;    Please note that pursuant to the License Agreement for this software,
  4. ;;;    [color=Red]"[c]opying of this computer program or its documentation except as
  5. ;;;    permitted by this License is copyright infringement under the laws of
  6. ;;;    your country.  If you copy this computer program without permission of
  7. ;;;    Autodesk, you are violating the law."[/color]

 
 
嗯。。。。。。。。。。。。
回复

使用道具 举报

20

主题

344

帖子

325

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
100
发表于 2022-7-6 12:25:13 | 显示全部楼层
最简单的解决方案是编写另一个lisp,将当前工作层“clayer”更改为您希望它们位于的任何层,然后分解该行,然后更改回您开始使用的内容。不过,这是一个非常好的解决方案。
回复

使用道具 举报

14

主题

78

帖子

64

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 12:31:36 | 显示全部楼层
 
但是,在运行LISP时,我当前的工作层不是0层。。。。
回复

使用道具 举报

20

主题

344

帖子

325

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
100
发表于 2022-7-6 12:46:09 | 显示全部楼层
我把它翻了一遍,不管是谁最初修改了LISP,几乎什么都没做。
 
我并没有亲自修改它,相反,我通过它找到了工作元素,并重新编写了所需的内容。
 
是的,就是这样。与acet wmfin函数有关。你可能需要对其进行编辑,以确定它必须位于哪一层。
 
*编辑*已在此处提出问题:
http://discussion.autodesk.com/forums/thread.jspa?threadID=646386
TL;DR,由于它在选择集上操作,并且每个项目可能位于不同的层上,因此它无法将它们放置在其原始层上,除非每个项目在acet wmfin中单独迭代。
 
*编辑编辑*我将保留第一个,因为它快速而干净,但显然acet wmfin将处理实体和选择集。我设置了一个快速循环来替换图层,并将颜色设置为“bylayer”您可能还可以想出如何将颜色重置为原始颜色。
  1. 3
回复

使用道具 举报

14

主题

78

帖子

64

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 12:53:44 | 显示全部楼层
谢谢,这很有帮助
回复

使用道具 举报

14

主题

78

帖子

64

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 13:03:02 | 显示全部楼层
最近一直在使用它,它在我的工作电脑上运行良好,但在家使用它(AutoCAD的相同版本等)时,我收到以下错误消息,然后该功能结束:
 
C: \txtexp。wmf:无法打开文件
 
 
有人能帮忙吗?
回复

使用道具 举报

20

主题

344

帖子

325

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
100
发表于 2022-7-6 13:10:20 | 显示全部楼层
试着键入命令“wmfin”,看看会发生什么。它会提示您输入一个。wmf文件。试试看你有没有txtexp。C:\驱动器中的wmf文件。
 
顺便说一句,我很高兴你能从中得到一些帮助。^
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-5 10:14 , Processed in 0.444808 second(s), 68 queries .

© 2020-2025 乐筑天下

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