Jump to content

lisp modification


chelsea1307

Recommended Posts

I have this lisp by kpblc and it takes everything in a block and changes its properties to by layer. Works great, except for attributes then you have to go back and attsync each block individually, is there a way with lisp to attsync all blocks within a dwg at once, and either add it to the lisp below or just a seperate lisp that does this or a command im totally missing. The other problem is Mtext, if mtext color is selected within the mtext editor dialog box is there a way to change it back to by layer without going into each mtext individually, also would be great added into this lisp but a seperate lisp you have that does the same thing would work too. I know a little about lisp so i can add to mine so it calls other lisps at the end to bring these in.

Author kpblc 
changes all blocks inserted in a dwg from by block/color to by layer.
(defun c:norm (/ *error* adoc lst_layer func_restore-layers)
 (defun *error* (msg)
   (func_restore-layers)
   (vla-endundomark adoc)
   (princ msg)
   (princ)
   ) ;_ end of defun

 (defun func_restore-layers ()
   (foreach item lst_layer
     (vla-put-lock (car item) (cdr (assoc "lock" (cdr item))))
     (vl-catch-all-apply
       '(lambda ()
          (vla-put-freeze (car item) (cdr (assoc "freeze" (cdr item))))
          ) ;_ end of lambda
       ) ;_ end of vl-catch-all-apply
     ) ;_ end of foreach
   ) ;_ end of defun

 (vl-load-com)
 (vla-startundomark
   (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
   ) ;_ end of vla-startundomark
 (vlax-for item (vla-get-layers adoc)
   (setq lst_layer (cons (list item
                               (cons "lock" (vla-get-lock item))
                               (cons "freeze" (vla-get-freeze item))
                               ) ;_ end of list
                         lst_layer
                         ) ;_ end of cons
         ) ;_ end of setq
   (vla-put-lock item :vlax-false)
   (vl-catch-all-apply '(lambda () (vla-put-freeze item :vlax-false)))
   ) ;_ end of vlax-for
 (vlax-for blk (vla-get-blocks adoc)
   (if (and (equal (vla-get-islayout blk) :vlax-false)
            (equal (vla-get-isxref blk) :vlax-false)
            ) ;_ end of and
     (progn
       (vlax-for subent blk
          ;(vla-put-layer subent "0");edit-> removed force to layer 0
         (vla-put-color subent 256)
         (vla-put-lineweight subent aclnwtbyblock)
         (vla-put-linetype subent "byblock")
         ) ;_ end of vlax-for
       ) ;_ end of progn
     ) ;_ end of if
   ) ;_ end of vlax-for
 (func_restore-layers)
 (vla-endundomark adoc)
(command "_regenall")
 (princ)
 ) ;_ end of defun

Link to comment
Share on other sites

battman and the sync button work a little fast then attsync each individual block but still looking for some way to do it all at once

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