+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Forum Newbie
    Using
    AutoCAD 2010
    Join Date
    Apr 2012
    Posts
    2

    Default Lisp to replace words

    Very good to the community and congratulations on your success,

    needed a little help to create a simple lisp routine. This is a lisp that allows me to change the words of a drawing: "Escala" for "Scale" and "Parte" for "Piece" no more. Only a change of words in the file, without having to select objects or anything.

    I know the Find and Replace Command, (its great), but I need this routine to apply it to 200 DWGS with EZscript-Pro.

    I do not mind changing the words of the routine every time I apply.

    Thank you very much and live all the experts in CAD

  2. #2
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,603

    Default

    BFind_LeeMac <------

    Allows you to Find and Replace multiple words on multiple files.

    Kudos to Lee Mac

  3. #3
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electrical.
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Great Syria , Lives in Abu Dhabi
    Posts
    3,742

    Default

    Be careful to have all strings not on locked layers

    Code:
    (defun c:TesT (/ ss i sn)
      (if (setq ss (ssget "_x" '((0 . "*TEXT") (1 . "Escala,Parte"))))
        (repeat (setq i (sslength ss))
          (setq sn (ssname ss (setq i (1- i))))
          (cond
            ((eq (cdr (assoc 1 (entget sn))) "Escala")
             (entmod
               (subst (cons 1 "Scale") (assoc 1 (entget sn)) (entget sn))
             )
            )
            (t
             (entmod
               (subst (cons 1 "Piece") (assoc 1 (entget sn)) (entget sn))
             )
            )
          )
        )
        (princ)
      )
      (princ)
    )
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  4. #4
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,737

    Default

    Registered forum members do not see this ad.

    Or if you don't want to use Lee's and the words are only part of the text (instead of the whole text). Also if string case should be ignored:
    Code:
    (vl-load-com)
    
    (defun c:TextRepl (/ pat str ss s p)
      (if (and (setq pat (getstring t "\nEnter string to search for: "))
               (setq str (getstring t "Enter replacement: "))
               (ssget (list '(0 . "TEXT,MTEXT")
                            (cons 1 (setq pat (strcat "*"
                                                      (apply 'strcat (mapcar '(lambda (c)
                                                                                (strcat "[" (strcase c) (strcase c t) "]"))
                                                                             (mapcar 'chr (vl-string->list pat))))
                                                      "*")))))
               (setq ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))))
        (progn
          (vlax-for eo ss
            (setq s (vla-get-TextString eo) p "")
            (while (wcmatch s pat)
              (while (not (wcmatch s (substr pat 2)))
                (setq p (strcat p (substr s 1 1)) s (substr s 2)))
              (setq p (strcat p str) s (substr s (1+ (/ (- (strlen pat) 2) 4)))))
            (if (not (eq s "")) (setq p (strcat p s)))
            (vla-put-TextString eo p))
          (vla-Delete ss)))
      (princ))
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

Similar Threads

  1. Lisp to replace text with block??
    By zride91 in forum AutoLISP, Visual LISP & DCL
    Replies: 21
    Last Post: 12th Jul 2012, 02:18 pm
  2. Number Counter Lisp (Words.lsp)? Help PLEASE
    By cbr shadow in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 14th Sep 2011, 05:52 pm
  3. Replies: 15
    Last Post: 6th Sep 2011, 08:32 am
  4. Lisp to change words in an Autocad drawing 2
    By davidson_cesar in forum AutoLISP, Visual LISP & DCL
    Replies: 13
    Last Post: 31st Mar 2011, 01:03 pm
  5. Lisp to change words in an Autocad drawing
    By davidson_cesar in forum AutoLISP, Visual LISP & DCL
    Replies: 15
    Last Post: 5th Mar 2011, 06:43 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts