+ Reply to Thread
Page 1 of 26 1 2 3 11 ... LastLast
Results 1 to 10 of 257
  1. #1
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,718

    Default Batch Find & Replace Text

    Registered forum members do not see this ad.

    Batch Find & Replace Text

    This program uses ObjectDBX to perform multiple text replacements on the current drawing or a complete directory (and subdirectories) of drawings. The program has the ability to search Text, MText, Block Attributes, Multileader Text, Table Cell Text and Dimension Override Text.

    The user may replace multiple search strings, and load & save lists of search strings for future use, saving time in program data entry.

    Users may perform a complete Find & Replace operation, or merely search for potential replacements using the 'Search Only' option. Following a search operation, a report is displayed informing the user of the replacements which would be performed should the user proceed with the replacement. The report also displays the object containing the text to be replaced, along with the entity handle of such object, and the drawing filename in which the object resides.

    The program provides the user additional refinement options, as displayed in the Options Dialog. This enables the user to control which objects are searched, whether locked layers are included in the replacement, search item case-sensitivity and whether the search item must appear as a complete word to be replaced.

    The generation of a report following a text replacement may also be controlled within the Options Dialog (the report will always be created following a search operation).

    Help and examples can be found in the Code Header:

    Dialog Preview:




    Options Dialog:



    Function Syntax: BFind

    Code:
    ;;-------------------------=={  Batch Find & Replace  }==------------------------;;
    ;;                                                                               ;;
    ;;  Will Find and Replace multiple strings entered by the user within Text,      ;;
    ;;  MText, Block Attributes, MLeader Text, Table Text and Dimensions within the  ;;
    ;;  current drawing, all currently open drawings and/or a directory              ;;
    ;;  (and subdirectories) of drawings.                                            ;;
    ;;                                                                               ;;
    ;;  If the 'Block Definitions' option is selected, all instances of the          ;;
    ;;  aforementioned text objects residing within block definitions are included   ;;
    ;;  in the search domain.                                                        ;;
    ;;                                                                               ;;
    ;;  Furthermore the user may choose which objects to search, whether the find    ;;
    ;;  string is case sensitive, and whether to restrict the search to whole words  ;;
    ;;  only.                                                                        ;;
    ;;-------------------------------------------------------------------------------;;
    ;;                                                                               ;;
    ;;  FUNCTION SYNTAX:  BFind                                                      ;;
    ;;                                                                               ;;
    ;;  Notes:                                                                       ;;
    ;;  ---------                                                                    ;;
    ;;  As expected, the known bug with ObjectDBX arises with regards to attribute   ;;
    ;;  alignment following modification. A sub-function has been included in an     ;;
    ;;  attempt to correct the change in position, however, a slight shift in        ;;
    ;;  position may be noticed. The attribute is realigned when the block is moved  ;;
    ;;  manually.                                                                    ;;
    ;;                                                                               ;;
    ;;  Also, when using the Batch Find and Replace, drawing thumbnails are lost     ;;
    ;;  upon saving with ObjectDBX. These return when the drawing is saved manually. ;;
    ;;                                                                               ;;
    ;;-------------------------------------------------------------------------------;;
    ;;                                                                               ;;
    ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com                          ;;
    ;;                                                                               ;;
    ;;-------------------------------------------------------------------------------;;
    ;;                                                                               ;;
    ;;  With additional thanks to Joe Burke for his tremendous help towards using    ;;
    ;;  Regular Expressions to eliminate the problem of MText formatting codes when  ;;
    ;;  performing replacements.                                                     ;;
    ;;                                                                               ;;
    ;;-------------------------------------------------------------------------------;;
    ;;  Version:                                                                     ;;
    ;;                                                                               ;;
    ;;  1.0:  24/05/2010  -  First Release                                           ;;
    ;;-------------------------------------------------------------------------------;;
    ;;  1.1:  26/05/2010  -  Added Options Button.                                   ;;
    ;;                    -  Updated String Replacement functions to allow for case  ;;
    ;;                       sensitivity options.                                    ;;
    ;;                    -  Upgraded StringRep function to allow replacement string ;;
    ;;                       to contain find string.                                 ;;
    ;;                    -  Fixed bug causing an unsaved drawing to be saved.       ;;
    ;;-------------------------------------------------------------------------------;;
    ;;  1.2:  29/05/2010  -  Added ability to perform multiple replacements.         ;;
    ;;-------------------------------------------------------------------------------;;
    ;;  1.3:  31/05/2010  -  Added ability to edit find and replace entry by         ;;
    ;;                       double-clicking.                                        ;;
    ;;                    -  Added 'Table Text' object to Options Dialog.            ;;
    ;;                    -  Added 'Find Whole Words Only' option to Options Dialog. ;;
    ;;                    -  Redesigned Options Dialog to accommodate new toggles,   ;;
    ;;                       added mnemonics.                                        ;;
    ;;-------------------------------------------------------------------------------;;
    ;;  1.4:  27/04/2010  -  Replaced 'StringRep' function with functions utilising  ;;
    ;;                       Regular Expressions to allow for MText formatting.      ;;
    ;;-------------------------------------------------------------------------------;;
    ;;  1.5:  29/09/2010  -  Reformatted code.                                       ;;
    ;;                    -  Drawings only saved if a replacement is made.           ;;
    ;;-------------------------------------------------------------------------------;;
    ;;  1.6:  03/10/2010  -  Added pick buttons to select text for Find/Replace      ;;
    ;;                       strings.                                                ;;
    ;;                    -  Added 'Match Case' option                               ;;
    ;;                    -  Added 'Find Whole Words Only' option                    ;;
    ;;-------------------------------------------------------------------------------;;
    ;;  1.7:  05/10/2010  -  Added 'Search Only' option in which the program will    ;;
    ;;                       search for multiple strings within the current drawing  ;;
    ;;                       and/or a directory (and subdirectories) of drawings,    ;;
    ;;                       subsequently producing a report detailing the number    ;;
    ;;                       of occurrences of each string and list of possible      ;;
    ;;                       changes should a replacement be performed.              ;;
    ;;                    -  Added error trap to drawing processing loop to prevent  ;;
    ;;                       crash should one drawing error.                         ;;
    ;;                    -  Added delay to DCL creation.                            ;;
    ;;-------------------------------------------------------------------------------;;
    ;;  1.8:  08/10/2010  -  Added Load & Save buttons to allow a set of search      ;;
    ;;                       items to be loaded and saved.                           ;;
    ;;-------------------------------------------------------------------------------;;
    ;;  1.9:  09/10/2010  -  Fixed bug involving capital 'S' being removed from      ;;
    ;;                       textstring during stacking formatting code removal.     ;;
    ;;                    -  Added code to allow 'special' characters to be used in  ;;
    ;;                       Find string.                                            ;;
    ;;-------------------------------------------------------------------------------;;
    ;;  2.0:  22/07/2011  -  Majority of program rewritten and reformatted to        ;;
    ;;                       include the following enhancements:                     ;;
    ;;                    -  Fixed tab stops in dialog to allow the user to use the  ;;
    ;;                       tab key to navigate between edit boxes.                 ;;
    ;;                    -  Added 'Where to Search' panel to allow the user to      ;;
    ;;                       restrict the search to Modelspace, Layout space or Both.;;
    ;;                    -  Added 'Block Definitions' to list of objects to search  ;;
    ;;                       to allow users to search text objects in blocks.        ;;
    ;;                    -  Added 'Current Directory' toggle to allow the user to   ;;
    ;;                       quickly select the current working directory to be      ;;
    ;;                       processed.                                              ;;
    ;;                    -  Added ability to add items to find/replace list by      ;;
    ;;                       pressing Enter from within either edit box.             ;;
    ;;                    -  Added ability to press Enter after entering Save        ;;
    ;;                       Reference without needing to click the OK button.       ;;
    ;;                    -  Added ability to press Enter after editing entry        ;;
    ;;                       without needing to click the OK button.                 ;;
    ;;                    -  Changed format of Saved Searches file for easier        ;;
    ;;                       manual editing.                                         ;;
    ;;                    -  Added ability to process 'All Open Drawings'.           ;;
    ;;-------------------------------------------------------------------------------;;
    A full description can be found here.

    Disclaimer: BFind.lsp is not entirely bug-free, as demonstrated by the information contained herein: I would hence advise against its usage in cases where heavily formatted MText is involved. However, it should, in most cases, perform successfully.

    When replacements are made, drawings will be saved in native format (i.e. if run in AutoCAD2010, will be saved as 2010 drawing).
    Attached Files
    Last edited by Lee Mac; 22nd Jul 2011 at 04:05 pm.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  2. #2
    Quantum Mechanic ReMark's Avatar
    Computer Details
    ReMark's Computer Details
    Operating System:
    Windows 7 Pro 64-bit
    Computer:
    Thinkmate
    Motherboard:
    Intel DX58SO2 LGA1366 X58
    CPU:
    Intel i7-960 Quad-core 3.20GHz 8MB cache
    RAM:
    12GB (3x4GB) PC3-106000 DDR3
    Graphics:
    nVidia Quadro 4000, 2GB GDDR5
    Primary Storage:
    150GB Velocipraptor 10,000 rpm
    Secondary Storage:
    none
    Monitor:
    Dell P24LLH - 24" wide screen LCD
    Discipline
    See details...
    ReMark's Discipline Details
    Occupation
    CAD Draftsman/Designer...chemical manufacturing.
    Discipline
    See details below.
    Details
    I work for a specialty chemical manufacturer. I do a little bit of everything from P&IDs to civil to architectural and structural.
    Using
    AutoCAD 2013
    Join Date
    Nov 2005
    Location
    Norwalk, CT USofA
    Posts
    33,058

    Default

    I think they call that a "teaser" Lee. Don't be playing with us! LOL
    "I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police

    Eat brains...gain more knowledge!

  3. #3
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,718

    Default

    Quote Originally Posted by ReMark View Post
    I think they call that a "teaser" Lee. Don't be playing with us! LOL
    Indeed I am - I have seen so many questions about a Batch Find and Replace, I thought I'd give it a shot.
    Last edited by Lee Mac; 24th Mar 2010 at 11:47 pm.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  4. #4
    Super Member asos2000's Avatar
    Computer Details
    asos2000's Computer Details
    Operating System:
    WinXP
    Using
    AutoCAD 2007
    Join Date
    Sep 2007
    Location
    Cairo Egypt
    Posts
    573

    Default

    Waiting for V1.0
    Sorry for my English.

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,718

    Default

    Code updated to Version 1.0
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  6. #6
    Super Member asos2000's Avatar
    Computer Details
    asos2000's Computer Details
    Operating System:
    WinXP
    Using
    AutoCAD 2007
    Join Date
    Sep 2007
    Location
    Cairo Egypt
    Posts
    573

    Default

    Congratulations
    Sorry for my English.

  7. #7
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,718

    Default

    Quote Originally Posted by asos2000 View Post
    Congratulations
    Thanks Asos,

    I'm pleased to have the basic program runnning, I have a few more ideas I may add in future to make the program function similar to the AutoCAD Find command.

    I'm glad you like it,

    Lee
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  8. #8
    Super Member asos2000's Avatar
    Computer Details
    asos2000's Computer Details
    Operating System:
    WinXP
    Using
    AutoCAD 2007
    Join Date
    Sep 2007
    Location
    Cairo Egypt
    Posts
    573

    Default

    The routine seems good but not working i dont know why

    Please see attached
    The image and the CAD file
    Attached Images
    Attached Files
    Sorry for my English.

  9. #9
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,718

    Default

    Yes, as I say in the first post, at this point, the replacement string cannot contain the find string, as the program would loop endlessly, as there would always be something to replace.

    EDIT: The next version will solve this problem
    Last edited by Lee Mac; 25th Mar 2010 at 12:54 am.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  10. #10
    Super Member asos2000's Avatar
    Computer Details
    asos2000's Computer Details
    Operating System:
    WinXP
    Using
    AutoCAD 2007
    Join Date
    Sep 2007
    Location
    Cairo Egypt
    Posts
    573

    Default

    Registered forum members do not see this ad.

    waiting for next version
    Sorry for my English.

Similar Threads

  1. Find and Replace text in several files.
    By guilhermecampos in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 27th Mar 2010, 07:24 pm
  2. Find & Replace Text
    By drewd1508 in forum AutoLISP, Visual LISP & DCL
    Replies: 25
    Last Post: 19th Mar 2010, 09:57 pm
  3. Find & Replace Text
    By happyunited in forum AutoCAD General
    Replies: 14
    Last Post: 4th Aug 2009, 05:44 pm
  4. Find/Replace text without a dialog box?
    By y49sides in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 11th Jul 2009, 11:43 pm
  5. Find/Replace text?
    By Ste1978 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 16th Nov 2007, 03:28 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