Jump to content

Recommended Posts

Posted

I have some blocks.do i can change all layer in blocks into layer "0" ?

Including text...and have adverse with anonymous blocks. Can you help me ! Thank for all !

Posted

An example I wrote a while ago:

 

;;---------------=={ Apply to Block Objects }==---------------;;
;;                                                            ;;
;;  Applies a supplied function to all objects in a block     ;;
;;  definition.                                               ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  _acblocks  - block collection in which block resides      ;;
;;  _blockname - name of block to apply function              ;;
;;  _function  - function to apply to all objects in block    ;;
;;------------------------------------------------------------;;
;;  Returns: List of results of evaluating function, else nil ;;
;;------------------------------------------------------------;;

(defun LM:ApplytoBlockObjects ( _acblocks _blockname _function / result )
 (
   (lambda ( _function / def )  
     (if
       (not
         (vl-catch-all-error-p
           (setq def
             (vl-catch-all-apply 'vla-item (list _acblocks  _blockname))
           )
         )
       )
       (vlax-for obj def (setq result (cons (_function obj) result)))
     )
   )
   (eval _function)
 )
 (reverse result)
)



;; Test Function to Move all Objects in a Block to Layer "0"
(defun c:test ( / acdoc acblk ss l ) (vl-load-com)

 (setq acdoc (vla-get-activedocument (vlax-get-acad-object))
       acblk (vla-get-blocks acdoc)
 )
 (if (setq ss (ssget "_+.:E:S" '((0 . "INSERT"))))
   (progn    
     (LM:ApplytoBlockObjects acblk (cdr (assoc 2 (setq l (entget (ssname ss 0)))))
       (function
         (lambda ( obj ) (vla-put-Layer obj "0"))
       )
     )
   )
 )
 (princ)
)

Posted

Why all the anonymous blocks?

Posted

hi LEE.

I HAVE A BLOCK: A CIRLCE, 2 TEXT. WITH YOUR LISP, I ONLY CHANGE LAYER FOR TEXT, BUT NO WITH COLOR TEXT AND CIRLCE TOO.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...