Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: FIND AND REPLACE BLOCK.

  1. #1
    Member
    Join Date
    2015-08
    Posts
    32
    Login to Give a bone
    0

    Post FIND AND REPLACE BLOCK.

    hi
    can anybody help me on this....
    is there any lisp program like a find & replace option
    i want to replace blocks in place of text.


    thanks.

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

    Default Re: FIND AND REPLACE BLOCK.

    Consider the BLOCKREPLACE Express Tool.

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

    Default Re: FIND AND REPLACE BLOCK.

    Quote Originally Posted by BlackBox View Post
    Consider the BLOCKREPLACE Express Tool.

    Cheers
    I do think the OP wants to replace a string of text with a block. I do not think the BLOCKREPLACE Express Tool does that. But I could be wrong.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  4. #4
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

    Default Re: FIND AND REPLACE BLOCK.

    Quote Originally Posted by Opie View Post
    I do think the OP wants to replace a string of text with a block. I do not think the BLOCKREPLACE Express Tool does that. But I could be wrong.
    Given the thread title, that is not at all what I get from:

    Quote Originally Posted by aijazahmed View Post
    i want to replace blocks in place of text.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  5. #5
    Member
    Join Date
    2015-08
    Posts
    32
    Login to Give a bone
    0

    Default Re: FIND AND REPLACE BLOCK.

    Thanks blackbox for "BLOCKREPLACE"
    But I didn’t get my answer. I checked “blockreplace” command is working for blocked object only. I need the program for text format to block object. Because In my drawing I have numbers like a 48, 65, 113.... in text format on different locations. I want to replace those numbers with some blocks.

  6. #6
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

    Default Re: FIND AND REPLACE BLOCK.

    Well I'll be...

    Quote Originally Posted by Opie View Post
    I do think the OP wants to replace a string of text with a block. I do not think the BLOCKREPLACE Express Tool does that. But I could be wrong.




    Quote Originally Posted by aijazahmed View Post
    Thanks blackbox for "BLOCKREPLACE"
    But I didn’t get my answer. I checked “blockreplace” command is working for blocked object only. I need the program for text format to block object. Because In my drawing I have numbers like a 48, 65, 113.... in text format on different locations. I want to replace those numbers with some blocks.
    So really... You want to 'Find and Replace Text with a Block'.

    Perhaps the simplest thing to do is for you to post a drawing that shows a 'before', and 'after' example.

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  7. #7
    Member
    Join Date
    2015-08
    Posts
    32
    Login to Give a bone
    0

    Default Re: FIND AND REPLACE BLOCK.

    Quote Originally Posted by BlackBox View Post
    So really... You want to 'Find and Replace Text with a Block'.

    Perhaps the simplest thing to do is for you to post a drawing that shows a 'before', and 'after' example.

    Cheers


    Thanks for reply ....and please find the attached sample drawing.....
    I hope it will be clear for you..

    thanks
    Attached Files Attached Files
    Last edited by BlackBox; 2013-07-23 at 08:16 PM.

  8. #8
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: FIND AND REPLACE BLOCK.

    Try this ...

    Code:
    (defun c:Test (/ b ss i e)
      ;;; Tharwat 27. 07. 2013 ;;;
      (if (and (setq b (getstring t "\n Specify Block name :"))
               (if (not (tblsearch "BLOCK" b))
                 (progn
                   (alert "Block name is not found in drawing !!")
                   nil
                 )
                 t
               )
               (progn (princ "\n Select texts to replace with a Block :")
                      (setq ss (ssget "_:L" '((0 . "*TEXT"))))
               )
          )
        (repeat (setq i (sslength ss))
          (setq e (ssname ss (setq i (1- i))))
          (if (entmake (list '(0 . "INSERT")
                             (cons 2 b)
                             (assoc 8 (entget e))
                             (assoc 10 (entget e))
                             '(41 . 1.)
                             '(42 . 1.)
                             '(43 . 1.)
                       )
              )
            (entdel e)
          )
        )
      )
      (princ)
    )

  9. #9
    Member
    Join Date
    2015-08
    Posts
    32
    Login to Give a bone
    0

    Default Re: FIND AND REPLACE BLOCK.

    Thank you very much…

    I checked with this lisp the problem is I need to select the text then it will replace with the block.
    But I don’t want select the text one by one. I need if I give a number it should find from selected area or (from the same .dwg file) then replace those numbers with block according to text alignment.

    Or at least update the program for me. The text should be replace with block according to text align.

    Please help me on this........

    Thanks.

  10. #10
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    0

    Default Re: FIND AND REPLACE BLOCK.

    Quote Originally Posted by aijazahmed View Post
    I checked with this lisp the problem is I need to select the text then it will replace with the block.
    But I don’t want select the text one by one. I need if I give a number it should find from selected area or (from the same .dwg file) then replace those numbers with block according to text alignment.

    Or at least update the program for me. The text should be replace with block according to text align.
    This routine prompts the user for text to search for, supports WCMATCH (i.e., ""*Text To Find*"), and is case sensitive... If a valid selection is made on the current tab, the user is then prompted to either select the desired block, or enter a valid block name, which is then inserted, rotated, and placed on the same layer as the source text entity (RText not included)... This routine also supports UNDO:

    Code:
    (vl-load-com)
    
    (defun c:FOO (/ *error* match block acDoc oSpace)
    
      (defun *error* (msg)
        (if acDoc (vla-endundomark acDoc))
        (cond ((not msg))                                                   ; Normal exit
              ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
              ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
        )
        (princ)
      )
    
      (if
        (and
          (princ "\n** Search supports \"WCMATCH\", and is case sensitive ** ")
          (setq match
                 (getstring T
                   "\nEnter text to find and replace with block: "
                 )
          )
          (ssget "_x"
                 (list '(0 . "MTEXT,TEXT")
                       (cons 1 match)
                       (cons 410 (getvar 'ctab))
                 )
          )
          (or
            (and
              (setq block
                     (car
                       (entsel
                         "\nSelect block to replace text, <Enter> for name: "
                       )
                     )
              )
              (= "INSERT" (cdr (assoc 0 (entget block))))
              (setq block (vla-get-effectivename (vlax-ename->vla-object block)))
            )
            (and
              (setq block
                     (getstring
                       T
                       "\nEnter name of block to replace text: "
                     )
              )
              (tblsearch "block" block)
            )
          )
        )
         (progn
           (vla-startundomark
             (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
           )
           (setq oSpace (vlax-get acDoc
                                  (if (= 1 (getvar 'cvport))
                                    'paperspace
                                    'modelspace
                                  )
                        )
           )
           (vlax-for x (vla-get-activeselectionset acDoc)
             (vla-put-layer
               (vla-insertblock
                 oSpace
                 (vla-get-insertionpoint x)
                 block
                 1.
                 1.
                 1.
                 (vla-get-rotation x)
               )
               (vla-get-layer x)
             )
             (vla-delete x)
           )
         )
        (cond (block (prompt "\n** Invalid block ** "))
              (match (prompt "\n** No matching text found ** "))
          )
      )
      (*error* nil)
    )
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Page 1 of 2 12 LastLast

Similar Threads

  1. 2007: Find & replace
    By nextvkin in forum AutoCAD General
    Replies: 6
    Last Post: 2015-09-06, 11:19 PM
  2. Find and Replace Attributed Block
    By xdbk07445198 in forum Dot Net API
    Replies: 1
    Last Post: 2012-12-05, 06:29 AM
  3. Find and replace
    By eric_keneson2 in forum AutoLISP
    Replies: 1
    Last Post: 2010-02-09, 04:26 PM
  4. Find a block attribute by Tag and replace Value
    By montana.fox in forum VBA/COM Interop
    Replies: 14
    Last Post: 2006-09-14, 03:07 PM
  5. Find & replace
    By markl.70662 in forum Revit Architecture - Wish List
    Replies: 4
    Last Post: 2005-05-25, 05:12 PM

Posting Permissions

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