Jump to content

attributed blocks to change layer of Attributes & color of Attributes=bylayer?


chico1201

Recommended Posts

Yes.. please try the following

 

(defun c:chgabla (/ ss ly doc)
 ;;    Tharwat 27.May.2014    ;;
 (if (and (/= (setq ly (getstring t "\n Specify Layer name :")) "")
          (if (not (tblsearch "LAYER" ly))
            (progn (alert (strcat "Layer name < " ly " > is not found !!")) nil)
            t
          )
          (princ "\n Select attributed blocks to change layer of Attributes ")
          (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1))))
     )
   (progn (vla-startUndomark (setq doc (vla-get-activedocument (vlax-get-acad-object))))
          ((Lambda (i / sn e)
             (while (setq sn (ssname ss (setq i (1+ i))))
               (setq e (tblobjname "BLOCK" (cdr (assoc 2 (entget sn)))))
               (while (setq e (entnext e))
                 (entmod (subst (cons 8 ly) (assoc 8 (entget e)) (entget e))))
               (foreach x (vlax-invoke (vlax-ename->vla-object sn) 'getattributes) (vla-put-layer x ly)[color="#f4a460"](vla-put-color x 256)[/color])
             )
           )
            -1
          )
          (vla-Endundomark doc)
   )
 )
 (princ)
)(vl-load-com)

As you can see, in the foreach loop, when reside the code for changing the layer you just had to add the code to change the color (256 is bylayer)

 

Cheers!

Link to comment
Share on other sites

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...