TheSwamp

CAD Forums => CAD General => Topic started by: craigr on August 15, 2012, 10:58:00 AM

Title: Block Editor Rename?
Post by: craigr on August 15, 2012, 10:58:00 AM
I've recieved a drawing from a Coworker that has many blocks in it.

When I go to edit them in the Block Editor, they have nonsensicle names such as 'A$4E676C4A'.

I would like the names to actually mean something like '8inchbolt' instead. But, I don't want to have to explode each one and then make a new block with the new name.

Is there a command to just rename them?

craigr
Title: Re: Block Editor Rename?
Post by: Rob... on August 15, 2012, 11:04:19 AM
There is a command "RENAME" but you don't get a preview of the block so you would have to know what they were from the name that they have now.
Title: Re: Block Editor Rename?
Post by: craigr on August 15, 2012, 11:05:20 AM
Got it. - Thanks

I don't know how I haven't run into that before.

craigr
Title: Re: Block Editor Rename?
Post by: Rob... on August 15, 2012, 11:06:16 AM
In 2011 the block editor has is an option to "save as".
Title: Re: Block Editor Rename?
Post by: dgorsman on August 15, 2012, 11:27:22 AM
Ah, yes, the joys of users discovering paste as block.  The users around here have been... educated... about not using that, precisely for that reason.
Title: Re: Block Editor Rename?
Post by: HasanCAD on August 16, 2012, 02:53:21 AM
Give this a try (http://www.theswamp.org/index.php?topic=42378.0;all)
Title: Re: Block Editor Rename?
Post by: Rob... on August 16, 2012, 05:42:10 AM
Give this a try (http://www.theswamp.org/index.php?topic=42378.0;all)

OP has LT, no lisp.
Title: Re: Block Editor Rename?
Post by: craigr on August 16, 2012, 07:32:01 AM
The 'Rename' thing worked great.

Though, as mentioned, it would be nice if there was a preview window so you don't have to remember the name of the block you want to change.

craigr
Title: Re: Block Editor Rename?
Post by: craigr on August 21, 2012, 10:02:37 AM
Another relate question....

Now that I have renamed their blocks to appropriate 'Standard' names, is there a way to change  the properties so that the block cannot be exploded?

Other than explode it and make a 'new block' with the same name and deselect the 'explode' option.

craigr

(edited) - Yes I DID look thru the properties box AND in the Block editor and haven't found the option. - It MAY be there, but I haven't been able to spot it.

(edit AGAIN) - I DID find it!!  - You have to open the Properties Bar within the Block editor. When I looked previously, I selected the block THEN opened the properties bar.

Craigr
Title: Re: Block Editor Rename?
Post by: Crank on August 21, 2012, 03:21:23 PM
Everybody could have told you that :P ;)

There is even an easier/faster way:
Title: Re: Block Editor Rename?
Post by: Daniel J. Ellis on August 22, 2012, 03:45:37 AM
Good way to take advantage of an annoying feature there, Crank :)

dJE
Title: Re: Block Editor Rename?
Post by: Dommy2Hotty on August 23, 2012, 02:07:24 PM
I use this:

Code: [Select]
(defun c:BlockRename ()
  (vl-load-com)
  (setq bname (vla-get-EffectiveName (vlax-ename->vla-object (car(entsel "\nSelect block: ")))))
  (command "rename" "block" bname pause)
  );DEFUN

Command: blockrename
Select block:
rename
Enter object type to rename
[Block/Dimstyle/LAyer/LType/Material/Style/Tablestyle/Ucs/VIew/VPort]: block
Enter old block name: A$C7EDB4DDE
Enter new block name: New Block Name

Command: nil
Title: Re: Block Editor Rename?
Post by: Lee Mac on August 23, 2012, 05:25:20 PM
Code: [Select]
(defun c:BlockRename ()
  (vl-load-com)
  (setq bname (vla-get-EffectiveName (vlax-ename->vla-object (car(entsel "\nSelect block: ")))))
  (command "rename" "block" bname pause)
  );DEFUN

A minor upgrade for you Dommy on the house:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:blockrename ( / *error* ent )
  2.     (setq *error* '(( m ) (princ)))    
  3.     (while
  4.         (progn (setvar 'errno 0) (setq ent (car (entsel "\nSelect Block: ")))
  5.             (cond
  6.                 (   (= 7 (getvar 'errno))
  7.                     (princ "\nMissed, try again.")
  8.                 )
  9.                 (   (= 'ename (type ent))
  10.                     (if (/= "INSERT" (cdr (assoc 0 (entget ent))))
  11.                         (princ "\nSelected object is not a Block.")
  12.                     )
  13.                 )
  14.             )
  15.         )
  16.     )
  17.     (if ent (command "_.-rename" "_B" (vla-get-effectivename (vlax-ename->vla-object ent)) "\\"))
  18.     (princ)
  19. )
Title: Re: Block Editor Rename?
Post by: craigr on August 24, 2012, 07:37:22 AM
Sometimes I feel like 'the red-headed stepchild' with you FULL CAD people.

:)
Title: Re: Block Editor Rename?
Post by: Kerry on August 24, 2012, 08:26:57 AM
< .. >

A minor upgrade for you Dommy on the house:


What other options are there ?

:)
Title: Re: Block Editor Rename?
Post by: Dommy2Hotty on August 24, 2012, 12:05:55 PM
Those are the types of things I want to start incorporating to go to the next level.  Much appreciated!!!  :kewl:


Code: [Select]
(defun c:BlockRename ()
  (vl-load-com)
  (setq bname (vla-get-EffectiveName (vlax-ename->vla-object (car(entsel "\nSelect block: ")))))
  (command "rename" "block" bname pause)
  );DEFUN

A minor upgrade for you Dommy on the house:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:blockrename ( / *error* ent )
  2.     (setq *error* '(( m ) (princ)))    
  3.     (while
  4.         (progn (setvar 'errno 0) (setq ent (car (entsel "\nSelect Block: ")))
  5.             (cond
  6.                 (   (= 7 (getvar 'errno))
  7.                     (princ "\nMissed, try again.")
  8.                 )
  9.                 (   (= 'ename (type ent))
  10.                     (if (/= "INSERT" (cdr (assoc 0 (entget ent))))
  11.                         (princ "\nSelected object is not a Block.")
  12.                     )
  13.                 )
  14.             )
  15.         )
  16.     )
  17.     (if ent (command "_.-rename" "_B" (vla-get-effectivename (vlax-ename->vla-object ent)) "\\"))
  18.     (princ)
  19. )
Title: Re: Block Editor Rename?
Post by: Lee Mac on August 24, 2012, 01:22:22 PM
You're very welcome Dommy  :-)
Title: Re: Block Editor Rename?
Post by: Crank on August 27, 2012, 05:41:19 PM
OK, I'm lost. What's happening here:
Code: [Select]
'(( m ) (princ))
Title: Re: Block Editor Rename?
Post by: Lee Mac on August 27, 2012, 05:54:07 PM
OK, I'm lost. What's happening here:
Code: [Select]
'(( m ) (princ))

Implied defun-q expression

Code - Auto/Visual Lisp: [Select]
  1. (setq *error* '(( m ) (princ))) == (defun-q *error* ( m ) (princ))

The interpreter will automatically assume that quoted list structure to be a function defined using defun-q and evaluate it as such.

Consider the following example:

Code - Auto/Visual Lisp: [Select]
  1. _$ (setq x '((a) (+ a 5)))
  2. ((A) (+ A 5))
  3. _$ (car x)
  4. (A)
  5. _$ (cadr x)
  6. (+ A 5)
  7. _$ (x 2)
  8. 7
  9. ((A) (+ A 5))
Title: Re: Block Editor Rename?
Post by: Crank on August 28, 2012, 02:07:24 AM
I see, thanks for the explanation.
Though I think that I'll stick to be using defun-q :) .