+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast
Results 1 to 10 of 37
  1. #1
    Senior Member Efeezy's Avatar
    Using
    MEP 2012
    Join Date
    Jan 2010
    Location
    Seattle WA
    Posts
    117

    Default Replace Selected Block Or Blocks With Another Block

    Registered forum members do not see this ad.

    DOES ANYONE HAVE A QUICK AND EASY WAY TO REPLACE A SELECTED BLOCK. ALSO IS THERE A WAY TO REPLACE MULTIPLE SLECTED BLOCKS AND REPLACE WITH A DIFFERENT BLOCK TYPICAL FOR ALL THE BLOCKS THAT ARE SELECTED? I HAVE A BIG A$$ PROJECT DUE FRIDAY AND NEED TO SWAP OUT ALOT OF BLOCKS NOW...

  2. #2
    Forum Deity
    Using
    Civil 3D 2008
    Join Date
    Sep 2006
    Location
    Pittsburgh, PA, USA
    Posts
    3,581

    Default

    Ouch... not so loud
    Have you tried the Express Tools' Blockreplace?

  3. #3
    Senior Member Efeezy's Avatar
    Using
    MEP 2012
    Join Date
    Jan 2010
    Location
    Seattle WA
    Posts
    117

    Default

    LOL sorry about that. Yes, I have express tools. The Blockreplace command replaces all the blocks i just want to replace the block that I have manually selected. I pulled an old stript and trying to alter it but not sure if I can pull it off though.

  4. #4
    Senior Member Efeezy's Avatar
    Using
    MEP 2012
    Join Date
    Jan 2010
    Location
    Seattle WA
    Posts
    117

    Default

    nope couldn't get the script to work I am a not good at writing or modifying lisp my bock i need to replace is smoke 1 with smoke rb

    ------------------------------------------

    Code:
    (defun c:rblk (/ pre nb ss i en ed)(while (or (not pre)(not (snvalid pre)))(setq pre (getstring "\nExisting BLOCKs Name Prefix:   ")))(while (not nb)(setq nb (getstring "\nNew BLOCK Name:   "))(cond ((not (snvalid nb))(setq nb nil))((tblsearch "BLOCK" nb))((findfile (strcat nb ".DWG"))(command "_.INSERT" nb)(command))(T (setq nb nil))))(and (setq ss (ssget "X" (list (cons 0 "INSERT")(cons 2 (strcat pre "*")))))(setq i (sslength ss))(while (not (minusp (setq i (1- i))))(setq en (ssname ss i)                    ed (entget en))(entmod (subst (cons 2 nb) (assoc 2 ed) ed))(entupd en)))(prin1))
    Last edited by SLW210; 10th Jan 2012 at 01:30 pm.

  5. #5
    Forum Deity
    Using
    Civil 3D 2008
    Join Date
    Sep 2006
    Location
    Pittsburgh, PA, USA
    Posts
    3,581

    Default

    I've had this in my archives for a long time, hope it works for you
    Attached Files

  6. #6
    Full Member manirpg's Avatar
    Computer Details
    manirpg's Computer Details
    Operating System:
    Windows Vista
    Computer:
    DELL
    RAM:
    2GB
    Monitor:
    TFT
    Using
    Revit MEP 2012
    Join Date
    May 2010
    Location
    Mumbai,INDIA.
    Posts
    50

    Default good one

    Good one.........its working fine...Mr.Efeezy, Are u got solution? if yes complete the target before due..................Congrats...

  7. #7
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    Jul 2009
    Posts
    267

    Default

    Quote Originally Posted by Efeezy View Post
    DOES ANYONE HAVE A QUICK AND EASY WAY TO REPLACE A SELECTED BLOCK. ALSO IS THERE A WAY TO REPLACE MULTIPLE SLECTED BLOCKS AND REPLACE WITH A DIFFERENT BLOCK TYPICAL FOR ALL THE BLOCKS THAT ARE SELECTED? I HAVE A BIG A$$ PROJECT DUE FRIDAY AND NEED TO SWAP OUT ALOT OF BLOCKS NOW...
    try Bre.lsp from Alan Thompson... It's works quite well..

    See updated CODE
    Last edited by SLW210; 10th Jan 2012 at 01:32 pm. Reason: Removed Lisp File

  8. #8
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2013
    Join Date
    Apr 2008
    Posts
    6,199

    Default

    Quote Originally Posted by gilsoto13 View Post
    try Bre.lsp from Alan Thompson... It's works quite well..
    I forgot all about that one. Haven't used it since the project I wrote it for.

    Original link
    DropBox
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  9. #9
    Super Member qball's Avatar
    Discipline
    Structural
    qball's Discipline Details
    Discipline
    Structural
    Details
    Structural / Architectural, Residential, Multi-family, Industrial, Wood frame, Steel, Masonry, Concrete, Tilt-up
    Using
    AutoCAD LT 2018
    Join Date
    Feb 2007
    Location
    Kelowna, Canada
    Posts
    741

    Default

    bre is good!

  10. #10
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2013
    Join Date
    Apr 2008
    Posts
    6,199

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by qball View Post
    bre is good!
    Glad you like it. I wish I could remove that old version gilsoto posted, but here's an updated version:

    Code:
    (defun c:BRE (/ *error* blk f ss temp)
      ;; Replace multiple instances of selected blocks (can be different) with selected block
      ;; Size and Rotation will be taken from original block and original will be deleted
      ;; Required subroutines: AT:GetSel
      ;; Alan J. Thompson, 02.09.10
    
      (vl-load-com)
    
      (defun *error* (msg)
        (and f *AcadDoc* (vla-endundomark *AcadDoc*))
        (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
          (princ (strcat "\nError: " msg))
        )
      )
    
      (if
        (and
          (AT:GetSel
            entsel
            "\nSelect replacement block: "
            (lambda (x / e)
              (if
                (and
                  (eq "INSERT" (cdr (assoc 0 (setq e (entget (car x))))))
                  (/= 4 (logand (cdr (assoc 70 (tblsearch "BLOCK" (cdr (assoc 2 e))))) 4))
                  (/= 4 (logand (cdr (assoc 70 (entget (tblobjname "LAYER" (cdr (assoc 8 e)))))) 4))
                )
                 (setq blk (vlax-ename->vla-object (car x)))
              )
            )
          )
          (princ "\nSelect blocks to be repalced: ")
          (setq ss (ssget "_:L" '((0 . "INSERT"))))
        )
         (progn
           (setq f (not (vla-startundomark
                          (cond (*AcadDoc*)
                                ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
                          )
                        )
                   )
           )
           (vlax-for x (setq ss (vla-get-activeselectionset *AcadDoc*))
             (setq temp (vla-copy blk))
             (mapcar (function (lambda (p)
                                 (vl-catch-all-apply
                                   (function vlax-put-property)
                                   (list temp p (vlax-get-property x p))
                                 )
                               )
                     )
                     '(Insertionpoint Rotation XEffectiveScaleFactor YEffectiveScaleFactor
                       ZEffectiveScaleFactor
                      )
             )
             (vla-delete x)
           )
           (vla-delete ss)
           (*error* nil)
         )
      )
      (princ)
    )
    
    (defun AT:GetSel (meth msg fnc / ent good)
      ;; meth - selection method (entsel, nentsel, nentselp)
      ;; msg - message to display (nil for default)
      ;; fnc - optional function to apply to selected object
      ;; Ex: (AT:GetSel entsel "\nSelect arc: " (lambda (x) (eq (cdr (assoc 0 (entget (car x)))) "ARC")))
      ;; Alan J. Thompson, 05.25.10
      (setvar 'errno 0)
      (while (not good)
        (setq ent (meth (cond (msg)
                              ("\nSelect object: ")
                        )
                  )
        )
        (cond
          ((vl-consp ent)
           (setq good (cond ((or (not fnc) (fnc ent)) ent)
                            ((prompt "\nInvalid object!"))
                      )
           )
          )
          ((eq (type ent) 'STR) (setq good ent))
          ((setq good (eq 52 (getvar 'errno))) nil)
          ((eq 7 (getvar 'errno)) (setq good (prompt "\nMissed, try again.")))
        )
      )
    )
    Last edited by alanjt; 2nd Dec 2010 at 05:10 pm.
    DropBox
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

Similar Threads

  1. block replace and dynamic blocks
    By Glen Smith in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 16th Jul 2014, 07:27 pm
  2. How to Copy as a block (with all selected external referance and blocks)
    By samcoozy in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 3
    Last Post: 4th May 2010, 10:55 am
  3. Replies: 3
    Last Post: 19th Mar 2010, 04:47 pm
  4. Replace Multiple blocks with one block
    By cbriana in forum AutoCAD General
    Replies: 17
    Last Post: 20th Jan 2010, 03:29 pm
  5. A Lisp to redefine selected blocks with current block scale as 1,1,1?
    By gilsoto13 in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 17th Sep 2009, 07:37 am

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