MiGo 发表于 2022-7-6 11:47:18

使用文字转换线型

我需要帮助。我正在REVIT 2010中进行一个项目,该程序无法识别包含字母的线型。因此,当我导入AutoCAD图形时,它们都是实线。
 
我要找的是一个lisp(适用于AutoCAD),它可以识别选定的线条线型,然后创建一条小线,然后创建一段文字,并在线条长度上重复此操作。如果有人知道这是否可能,请告诉我。
 
目前,我只是手动操作,这非常耗时。

eldon 发表于 2022-7-6 11:59:01

也许你会对此感兴趣。
 
我将ExpressTools文本分解更改为分解行(lnexp.lsp)。正如您在图片中通过夹点看到的那样,底线是一条线,而顶线分解为单独的线。文本不再是文本,而是多段线。
 
;;
;;;
;;;    By Dominic Panholzer
;;;
;;;    TXTEXP.LSP
;;;    Copyright © 1999 by Autodesk, Inc.
;;;
;;;    Your use of this software is governed by the terms and conditions of the
;;;    License Agreement you accepted prior to installation of this software.
;;;    Please note that pursuant to the License Agreement for this software,
;;;    "opying of this computer program or its documentation except as
;;;    permitted by this License is copyright infringement under the laws of
;;;    your country.If you copy this computer program without permission of
;;;    Autodesk, you are violating the law."
;;;
;;;    AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
;;;    AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
;;;    MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.AUTODESK, INC.
;;;    DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
;;;    UNINTERRUPTED OR ERROR FREE.
;;;
;;;    Use, duplication, or disclosure by the U.S. Government is subject to
;;;    restrictions set forth in FAR 52.227-19 (Commercial Computer
;;;    Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
;;;    (Rights in Technical Data and Computer Software), as applicable.
;;;
;;;----------------------------------------------------------------
;;;
;;;External Functions:
;;;
;;;   ACET-ERROR-INIT         --> ACETUTIL.FAS   Intializes bonus error routine
;;;   ACET-ERROR-RESTORE      --> ACETUTIL.FAS   Restores old error routine
;;;   ACET-GEOM-ZOOM-FOR-SELECT --> ACETUTIL.FAS   Zoom boundry to include points given
;;;   ACET-LAYER-LOCKED         --> ACETUTIL.FAS   Checks to see if layer is locked
;;;   ACET-GEOM-PIXEL-UNIT      --> ACETUTIL.FAS   Size of pixel in drawing units
;;;   ACET-GEOM-TEXTBOX         --> ACETUTIL.FAS   Returns the textbox for any text
;;;   ACET-GEOM-MIDPOINT      --> ACETUTIL.FAS   Returns midpoint between two points
;;;   ACET-GEOM-VIEW-POINTS   --> ACETUTIL.FAS   Returns corner points of screen or viewport
;;;   ACET-STR-FORMAT         --> ACETUTIL.ARX   String builder
;;;   ACET-WMFIN                --> ACETUTIL.FAS   Brings in WMF file
;;;
;   Amended by eldon to explode a line January 2009

(defun c:lnexp (/ grplst getgname blknm FLTR GLST GDICT SS VIEW UPLFT TMPFIL TBX
                  TMPFIL CNT PT1 PT2 ENT TXT TXTYP PTLST ZM LOCKED GNAM vpna vplocked)
(acet-error-init
       (list
      (list   "cmdecho" 0
                "highlight" 1
                "osmode" 0
                "Mirrtext" 1
                "limcheck" 0
      )
      T
       )
)

; --------------------- GROUP LIST FUNCTION ----------------------
;   This function will return a list of all the group names in the
;   drawing and their entity names in the form:
;   ((<ename1> . <name1>) ... (<enamex> . <namex>))
; ----------------------------------------------------------------

(defun acet-txtexp-grplst (/ GRP ITM NAM ENT GLST)

   (setq GRP(dictsearch (namedobjdict) "ACAD_GROUP"))
   (while (setq ITM (car GRP))       ; While edata item is available
   (if (= (car ITM) 3)             ; if the item is a group name
       (setq NAM (cdr ITM)         ; get the name
             GRP (cdr GRP)         ; shorten the edata
             ITM (car GRP)         ; get the next item
             ENT (cdr ITM)         ; which is the ename
             GRP (cdr GRP)         ; shorten the edata
             GLST                  ; store the ename and name
               (if GLST
                   (append GLST (list (cons ENT NAM)))
                   (list (cons ENT NAM))
               )
       )
       (setq GRP (cdr GRP))          ; else shorten the edata
   )
   )
   GLST                              ; return the list
)

; ------------------- GET GROUP NAME FUNCTION --------------------
;   This function returns a list of all the group names in GLST
;   where ENT is a member. The list has the same form as GLST
; ----------------------------------------------------------------

(defun acet-txtexp-getgname (ENT GLST / GRP GDATA NAM NLST)
   (if (and GLST (listp GLST))
   (progn
       (foreach GRP GLST
         (setq GDATA (entget (car GRP)))
         (foreach ITM GDATA                   ; step through the edata
         (if (and
               (= (car ITM) 340)            ; if the item is a entity name
               (eq (setq NAM (cdr ITM)) ENT) ; and the ename being looked for
               )
             (setq NLST                     ; store the ename and name
                     (if NLST
                     (append NLST (list (cons (car GRP) (cdr GRP))))
                     (list (cons (car GRP) (cdr GRP)))
                     )
             )
         )
         )
       )
   )
   )
   NLST
)

; ----------------------------------------------------------------
;                        MAIN PROGRAM
; ----------------------------------------------------------------

(if (and                                                ; Are we in plan view?
       (equal (car (getvar "viewdir")) 0 0.00001)
       (equal (cadr (getvar "viewdir")) 0 0.00001)
       (> (caddr (getvar "viewdir")) 0)
   )

   (progn

   (prompt "\nSelect line to be EXPLODED: ")

   (Setq FLTR    '((-4 . "<AND")
                     ;(-4 . "<OR")                      ; filter for mtext and text
                     ;(0 . "MTEXT")
                     ;(0 . "TEXT")
                     ;(-4 . "OR>")
                     (-4 . "<NOT")
                         (102 . "{ACAD_REACTORS")      ; and not leader text
                     (-4 . "NOT>")
                     (-4 . "AND>")
                  )
         GLST   (acet-txtexp-grplst)                           ; Get all the groups in drawing
         GDICT    (if GLST
                      (dictsearch (namedobjdict) "ACAD_GROUP")
                  )
         SS       (ssgetFLTR)
         CNT      0
   )
   ;; filter out the locked layers
   (if SS
       (setq SS (car (bns_ss_mod SS 1 T)))
   ) ;if

   ;; if we have anything left
   (if SS
       (progn
         (setq CNT 0)                                 ; Reset counter
         (while (setq ENT (ssname SS CNT))            ; step through each object in set

         (and
             GLST                                     ; if groups are present in the drawing
             (setq GNAM (acet-txtexp-getgname ENT GLST))          ; and the text item is in one or more
             (foreach GRP GNAM                        ; step through those groups
               (command "_.-group" "_r"               ; and remove the text item
               (cdr GRP) ENT ""
               )
             )
         )

         (setq TBX (acet-geom-textbox (entget ENT) 0))   ; get textbox points

         (setq TBX (mapcar '(lambda (x)
                              (trans x 1 0)         ; convert the points to WCS
                              )
                     TBX
                     )
         )

         (setq PTLST (append PTLST TBX))            ; Build list of bounding box
                                                      ; points for text items selected

         (setq CNT (1+ CNT))                        ; get the next text item
         ); while

         (setq PTLST (mapcar '(lambda (x)
                              (trans x 0 1)         ; convert all the points
                              )                     ; to the current ucs
                     PTLST
                   )
         )

         (if (setq ZM (acet-geom-zoom-for-select PTLST))          ; If current view does not contain
         (progn                                     ; all bounding box points
             (setq ZM
               (list
               (list (- (caar ZM) (acet-geom-pixel-unit))   ; increase zoom area by
                     (- (cadar ZM) (acet-geom-pixel-unit))    ; one pixel width to
                     (caddar ZM)                  ; sure nothing will be lost
               )
               (list (+ (caadr ZM) (acet-geom-pixel-unit))
                     (+ (cadadr ZM) (acet-geom-pixel-unit))
                     (caddr (cadr zm))
               )
               )
             )
             (if (setq vpna (acet-currentviewport-ename))
               (setq vplocked (acet-viewport-lock-set vpna nil))
             );if
             (command "_.zoom" "_w" (car ZM) (cadr ZM)); zoom to include text objects
         )
         )

         (setq VIEW   (acet-geom-view-points)
               TMPFIL   (strcat (getvar "tempprefix") "txtexp.wmf")
               PT1      (acet-geom-midpoint (car view) (cadr view))
               PT2      (list (car PT1) (cadadr VIEW))
         )

         (if (acet-layer-locked (getvar "clayer"))       ; if current layer is locked
         (progn
             (command "_.layer" "_unl" (getvar "clayer") ""); unlock it
             (setq LOCKED T)
         )
         )

         (command "_.mirror" SS "" PT1 PT2 "_y"
                  "_.WMFOUT" TMPFIL SS "")

         (if (findfile tmpfil)                           ; Does WMF file exist?
         (progn
             (command "_.ERASE" SS "")                   ; erase the orignal text
             (setq ss (acet-wmfin TMPFIL))               ; insert the WMF file
             (command "_.mirror" ss "" PT1 PT2 "_y")
         ) ;progn
         ) ;if


         (if LOCKED
         (command "_.layer" "_lock" (getvar "clayer") "") ; relock if needed
         ) ;if

         (if ZM (command "_.zoom" "_p"))            ; Restore original view if needed
         (if vplocked
             (acet-viewport-lock-set vpna T) ;re-lock the viewport if needed.
         );if
         (prompt (acet-str-format "\n%1 text object(s) have been exploded to lines."CNT))
         (prompt "\nThe line objects have been placed on layer 0.")
       )
   )
   )
   (prompt "\nView needs to be in plan (0 0 1).")
);if equal
(acet-error-restore)                                  ; Retsore values
(princ)
)


(princ)

MiGo 发表于 2022-7-6 12:02:30

我可以更改defun的名称以不覆盖快速工具lisp吗?
 
我只是不想卷入任何关于工作界限的问题。

eldon 发表于 2022-7-6 12:16:49

如果您向下滚动到我添加了关于更改它的注释的地方,我调用了函数“lnexp”(行分解),这样它就不会覆盖原始的txtexp。

MiGo 发表于 2022-7-6 12:19:15

我注意到你把它改成了lnexp。我试试看,谢谢。

eldon 发表于 2022-7-6 12:27:21

一个小小的警告,我发现对于长线,缩放并不完美,所以要准备好调整每条端点,以获得相同的整体尺寸。

MiGo 发表于 2022-7-6 12:36:41

它似乎从原始位置删除了这条线,它们的字母在X轴和Y轴上镜像显示,而不是0,0。

MiGo 发表于 2022-7-6 12:41:17

我正在绘制的图纸是现场平面图,因此这些单元被设置为英尺。当我把它改为英寸时,线条现在显示在开始的地方,但字母仍然颠倒。

eldon 发表于 2022-7-6 12:52:04

它看起来并不完美,我确实不得不把这句话的内容镜像出来。它还将所有内容更改为第0层,使其线宽为零,仅举几例,但它确实分解了线。
 
它的工作原理是从图形中导出WMF图像,然后重新导入图像。
 
也许你需要做太多的编辑才能发挥作用。
页: [1]
查看完整版本: 使用文字转换线型