+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 14 of 14
  1. #11
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,177

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by mattdalgety View Post
    Works like a charm.

    Cheers guys, absolute legends.
    You are welcome anytime.

  2. #12
    Forum Deity David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    2,545

    Default

    This should work with any release of AutoCAD. Both BLOCK Table definitions must exist in the current dwg.

    Code:
    (defun c:rblk (/ a b ss i en ed fe fd bl td bn in f)
      (while (or (not a)
                 (not (tblsearch "BLOCK" a)))
             (setq a (strcase (getstring "\nOld BLOCK a Name:  "))))
    
      (while (or (not b)
                 (not (tblsearch "BLOCK" b))
                 (= a b))
             (setq b (strcase (getstring "\nNew BLOCK b Name:  "))))
    
      (princ (strcat "\nUpdating Stand Alone BLOCK " a  " To BLOCK " b "\n"))
      (and (setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 a))))
           (princ (strcat "\t" (itoa (sslength ss)) " Found"))
           (setq i 0)
           (while (setq en (ssname ss i))
                  (setq ed (entget en))
                  (entmod (subst (cons 2 b) (assoc 2 ed) ed))
                  (setq i (1+ i))))
    
      (setq bl nil)
      (princ (strcat "\nSearching BLOCK " a  " To BLOCK " b "\n"))
      (while (setq td (tblnext "BLOCK" (not td)))
             (princ "\t\t\t\r")
             (prin1 bl)
             (setq bn (cdr (assoc  2 td))
                   fe (cdr (assoc -2 td))
                    f nil)
             (while (and (not f)
                         (setq fe (entnext fe)))
                    (setq fd (entget fe))
                    (and (= "INSERT" (cdr (assoc 0 fd)))
                         (setq in (cdr (assoc 2 fd)))
                         (= in a)
                         (cond ((member in bl) (setq f T))
                               (T (setq f T
                                       bl (cons bn bl)))))))
    
      (foreach bn bl
          (setq td (tblsearch "BLOCK" bn)
                fe (cdr (assoc -2 td)))
          (entmake td)
          (while fe
             (setq fd (entget fe))
             (and (= (cdr (assoc 0 fd)) "INSERT")
                  (= (cdr (assoc 2 fd)) a)
                  (setq fd (subst (cons 2 b) (assoc 2 fd) fd)))
             (entmake fd)
             (setq fe (entnext fe)))
          (entmake (list (cons 0 "ENDBLK")(cons 8 "0"))))
    
      (command "_.REGENALL")
      (prin1))
    I know it will work with regular, anonymous and attributed
    blocks. Stand alone inserts and nested blocks as well.

    I have no clue as to dynamic

    -David
    R12 (Dos) - A2K

  3. #13
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,533

    Default

    David,

    I don't believe that method will yield the desired results if attribute tags differ between the two block definitions.

    Lee
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  4. #14
    Forum Deity David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    2,545

    Default

    Registered forum members do not see this ad.

    Lee, You're right. I did think the OP was looking for the geometry to be changed. I have many instances where the data is retained but the model is modified. -David
    R12 (Dos) - A2K

Similar Threads

  1. Explode block except named
    By LISP2LEARN in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 5th Apr 2018, 08:51 am
  2. replace an object (rectangle) with a named block and keep the hyperlink
    By Jaap Marchal in forum AutoLISP, Visual LISP & DCL
    Replies: 18
    Last Post: 15th Mar 2017, 05:17 pm
  3. Inserting a block in named UCS then moving it in WCS
    By Dorian Gray in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 2nd Mar 2016, 02:49 am
  4. dynamic block + named view + model space = broken link...
    By baker in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 2nd Apr 2013, 06:23 pm
  5. Open a drawing to a named view
    By AutoCAD Tips Blog in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 28th Sep 2006, 03:50 am

Tags for this Thread

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