Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Anonymous / *U... blocks

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
Anonymous
848 Views, 10 Replies

Anonymous / *U... blocks

I've developed a couple of lisp routines that look for specific block names and edits those blocks.  However, at least half the blocks we use are dynamic, so we end up with a lot of *U... blocks which the routines don't recognize as the same block.

 

Is there a way to automatically rename blocks back to their original name without losing their dynamic properties?  If at all possible, I'd this to be done without having to enter in any information (i.e. block names), select blocks, match blocks to their names, etc.

 

Thanks for your help.

10 REPLIES 10
Message 2 of 11
stevor
in reply to: Anonymous

One means can be to use attributes.
S
Message 3 of 11
M_Hensley
in reply to: Anonymous

Dynamic blocks will always have the anonymous name once they are changed in any way. What you need to do is get the effective name using vlisp. The effective name is the same as the original block name. Here is a simple example to get the effective name of one block.

 

(vl-load-com)

(setq enb (entsel))

(vlax-get-property (vlax-ename->vla-object (car enb)) "effectivename")

Message 4 of 11
Anonymous
in reply to: M_Hensley

I'm a little lost on how to incorporate this vlisp into my code.  I'm not at all familiar with how to use vlisp in my programming.  Could you help me apply it to the following routine?

 

(if
    (setq BLKSS (ssget "X" '((2 . "NCS_Grid - Dynamic"))))
    (foreach BLK (mapcar 'cadr (ssnamex BLKSS))
      (setq
        BLKDATA (entget BLK)
        BLKSCL (rtos (cdr (assoc 41 BLKDATA)) 2 0)
        LAYNAME (strcat "A-Anno-Grid-Iden-" BLKSCL)
        ) ;end setq
      (command
        "-layer" "new" LAYNAME "color" "94" LAYNAME "ltype" "Phantom2" LAYNAME ""
        "chprop" BLK "" "layer" LAYNAME ""
        ) ;end command
      ) ;end foreach
    ) ;end if

Message 5 of 11
_Tharwat
in reply to: Anonymous

What are you trying to accomplish with the Dynamic Blocks ?

 

Regards.

 

Tharwat

Message 6 of 11
Anonymous
in reply to: _Tharwat

I don't understand how your question relates.  We use our dynamic blocks for all sorts of things:  doors with stretchable sizes, room and ceiling tags with togglable leaders, millwork elevations with visibility settings for drawers/shelves, etc.

Message 7 of 11
_Tharwat
in reply to: Anonymous

My question is , what are you expecting from a routine to do ?

 

Thanks

Message 8 of 11
Anonymous
in reply to: _Tharwat

The code I posted above is part of a routine that places blocks on specific layers based on the block name and insertion scale.  I have another routine that changes the grid location attribute of our view titles (again requiring the block name) based on the drawing name, the name of the titleblock insert, and its location on the sheet.

Message 9 of 11
_Tharwat
in reply to: Anonymous

Check this out Buddy ...

 

(defun Move-Dyn-Block-To-layer (Blkname LayerName / ss)
; Tharwat 17. 06. 2011
 (vl-load-com) (if (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 (strcat Blkname ",`*U*"))) ) ) ((lambda (i / sset e) (while (setq sset (ssname ss (setq i (1+ i)))) (if (eq Blkname (vla-get-EffectiveName (vlax-ename->vla-object sset)) ) (entupd (cdr (assoc -1 (entmod (subst (cons 8 LayerName) (assoc 8 (setq e (entget sset))) e ) ) ) ) ) ) ) ) -1 ) (princ) ) )

 And you can call the sub-routine with the following code to change the layer that a specific Dynamic Block lays on to another .

 

(Move-Dyn-Block-To-layer "Blkname" "LayerName")

 Tharwat

Message 10 of 11
Shneuph
in reply to: Anonymous


@Anonymous wrote:

I'm a little lost on how to incorporate this vlisp into my code.  I'm not at all familiar with how to use vlisp in my programming.  Could you help me apply it to the following routine?

 

(if
    (setq BLKSS (ssget "X" '((2 . "NCS_Grid - Dynamic"))))
    (foreach BLK (mapcar 'cadr (ssnamex BLKSS))
      (setq
        BLKDATA (entget BLK)
        BLKSCL (rtos (cdr (assoc 41 BLKDATA)) 2 0)
        LAYNAME (strcat "A-Anno-Grid-Iden-" BLKSCL)
        ) ;end setq
      (command
        "-layer" "new" LAYNAME "color" "94" LAYNAME "ltype" "Phantom2" LAYNAME ""
        "chprop" BLK "" "layer" LAYNAME ""
        ) ;end command
      ) ;end foreach
    ) ;end if



I don't think it is going to work the way you are going about it with the selection set filter.  You'll have to step through each block checking the effective name and then change the block to the new layer.  Maybe something like this will work better for you?...

(vl-load-com)
(if
  (setq BLKSS (ssget "X" '((0 . "Insert"))))
  (foreach BLK (mapcar 'cadr (ssnamex BLKSS))
    (setq
      vl-block (vlax-ename->vla-object blk)
      BLKEffectivename (vla-get-effectivename vl-block)
      BLKDATA (entget BLK)
      BLKSCL (rtos (cdr (assoc 41 BLKDATA)) 2 0)
      LAYNAME (strcat "A-Anno-Grid-Iden-" BLKSCL)
      );end setq
    (if (= BLKEffectivename "NCS_Grid - Dynamic")
      (progn
        (command
          "-layer" "new" LAYNAME "color" "94" LAYNAME "ltype" "Phantom2" LAYNAME ""
          "chprop" BLK "" "layer" LAYNAME ""
          );end command
        );progn
      );end if
    );end foreach
  );end if

 

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
Message 11 of 11
Anonymous
in reply to: Shneuph

Thanks, Shneuph!  That's exactly what I was looking for; I just didn't know how to incorporate the vlisp to target the intended block.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost