Page 3 of 3 FirstFirst 123
Results 21 to 22 of 22

Thread: Complex Block Swap?

  1. #21
    100 Club
    Join Date
    2012-08
    Posts
    111
    Login to Give a bone
    0

    Default Re: Complex Block Swap?

    Thanks, ccowgill
    It's works!!

    Best Regards!

  2. #22
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,507
    Login to Give a bone
    0

    Default Re: Complex Block Swap?

    Quote Originally Posted by fa_veneno23141159 View Post
    It's your routine tedg.
    This routine is exactly I need. Help me , please...

    Thanks
    As Chris Cowgill suggested, removing the ":S" from the code will allow you to window many different blocks.

    However.. you need to select the "Single" option if you're changing all the selected different blocks to one type of block.
    If you choose "Global" it will only change one type of block in your selection to the other block you choose.

    Code:
    (defun c:blkreplacer (/ answr ent idx newname obj ss)
      (vl-load-com)
      ;;setup default on first run
      (if (not jmm-replaceall)
        (setq jmm-replaceall "Single")
        )
      (command ".undo" "be")
      ;;if the user selects something, inputs a ne block name AND it exists in the dwg...
      (if (and (setq ss (ssget '((0 . "INSERT"))));;REMOVED THE :S	   
                 (progn
    	     (initget "Single Global")
    	     (if (setq answr (getkword "\nReplace just this block or Globally replace?[Single/Global]: "))
    	       (setq jmm-replaceall answr)
    	       (setq answr jmm-replaceall)
    	       )
    	     )
    	   (setq newname (getstring "\nBlock name to replace with: "))
    	   (tblobjname "BLOCK" newname)
    	   )
        (progn
          (if (eq jmm-replaceall "Global");;get ALL occurances if it's Global, else use the original ss
    	(setq ss (ssget "x" (list '(0 . "INSERT") (assoc 2 (entget (ssname ss 0))))))
    	)
          (setq idx -1)
          (while (setq ent (ssname ss (setq idx (1+ idx))))
    	(setq obj (vlax-ename->vla-object ent))
    	(vla-put-name obj newname);;change the name
    	(vla-update obj)
    	)
          )
        )
      (command ".undo" "end")
      (princ (strcat "\nReplaced " (itoa idx) " blocks......"))
      (princ)
      )

Page 3 of 3 FirstFirst 123

Similar Threads

  1. 2014: Complex Dynamic Block Issues
    By mbrandt5 in forum Dynamic Blocks - Technical
    Replies: 15
    Last Post: 2015-04-27, 10:55 PM
  2. 2014: Complex Dynamic Block problem
    By gambibolduc2563069 in forum Dynamic Blocks - Technical
    Replies: 1
    Last Post: 2014-02-25, 09:54 PM
  3. 2012: Complex Block Color
    By alien_srp in forum AutoCAD LT - General
    Replies: 5
    Last Post: 2012-05-03, 05:47 PM
  4. Complex Block (I think)
    By mike.mccall in forum Dynamic Blocks - Technical
    Replies: 1
    Last Post: 2010-07-27, 07:11 PM
  5. Solids-block swap
    By bruce.jones542083 in forum AutoLISP
    Replies: 2
    Last Post: 2009-04-03, 02:18 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
  •