Author Topic: Block Editor Rename?  (Read 10537 times)

0 Members and 1 Guest are viewing this topic.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: Block Editor Rename?
« Reply #15 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. )

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Block Editor Rename?
« Reply #16 on: August 24, 2012, 01:22:22 PM »
You're very welcome Dommy  :-)

Crank

  • Water Moccasin
  • Posts: 1503
Re: Block Editor Rename?
« Reply #17 on: August 27, 2012, 05:41:19 PM »
OK, I'm lost. What's happening here:
Code: [Select]
'(( m ) (princ))
Vault Professional 2023     +     AEC Collection

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Block Editor Rename?
« Reply #18 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))

Crank

  • Water Moccasin
  • Posts: 1503
Re: Block Editor Rename?
« Reply #19 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 :) .
Vault Professional 2023     +     AEC Collection