Results 1 to 2 of 2

Thread: Rename block name

  1. #1
    Member
    Join Date
    2010-04
    Posts
    2
    Login to Give a bone
    0

    Post Rename block name

    İf interesting to change block name, use this autolisp program..
    Code:
    ;*******************************************
    ;
    ;          Rename block name                
    ;         (change block name)               
    ;                                           
    ;*******************************************
    
    (defun c:rbk (/ blkselect )
    
    (setq blkselect (entget(car(entsel "Select block to view NAMES : ")))
          blkname   (cdr(assoc 2 blkselect)) )
    
    (princ (strcat "->>> " (cdr (assoc 2 blkselect)) " <<<-" ))
      
    (setq blknew (getstring t "\nEnter new block name: "))
     
    (command "_.rename" "_block" blkname blknew)
    (prompt "\nYour block name renamed...")
    (princ)
    )
    
    (Princ "Use command  > rbk < to change block name !")
    Attached Files Attached Files

  2. #2
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: Rename block name

    Nice way to make a introduction. Most just request/demand something to be written.

    A little food for thought...

    Code:
    (defun c:RBK (/ ent name new)
      ;; conditional variable to make sure object selected
      (if (and (setq ent (car (entsel "\nSelect block to rename: ")))
               ;; check to make sure object is a block
               (or (eq "INSERT" (cdr (assoc 0 (entget ent))))
                   (alert "Invalid object!")
               )
               ;; print block name to command line
               (princ (strcat "\n->>> "
                              (setq name (cdr (assoc 2 (entget ent))))
                              " <<<-"
                      )
               )
               ;; prompt for new block name and make sure result not equal to ""
               (/= "" (setq new (getstring T "\nspecify new block name: ")))
          )
        (cond
          ;; check if new name already exists
          ((tblsearch "block" new) (alert (strcat "Block: " new " already exists.")))
          ;; check if new name is valid
          ((not (snvalid new)) (alert (strcat "Invalid block name: " new)))
          ;; valid name, rename block
          ((snvalid new)
           (command "_.rename" "_block" name new)
           (alert (strcat "\nBlock \"" name "\" renamed to \"" new "\""))
          )
        )
      )
      (princ)
    )
    I did my best to comment everything.

Similar Threads

  1. Replies: 6
    Last Post: 2012-08-15, 04:55 PM
  2. Multiple block Rename
    By BCrouse in forum AutoLISP
    Replies: 7
    Last Post: 2006-08-08, 04:24 PM
  3. Copy and rename a block
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 7
    Last Post: 2006-02-01, 09:06 PM
  4. Rename block
    By kennet.sjoberg in forum AutoLISP
    Replies: 2
    Last Post: 2004-09-21, 10:48 PM
  5. Rename block instance
    By jkipfer in forum AutoCAD General
    Replies: 2
    Last Post: 2004-07-15, 12:15 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
  •