Jump to content

Recommended Posts

Posted

Please help me, i have this lisp ,

set all objects including blocks to color byblock and then set to color 200, except for dynamic blocks it only works the first time and then that's it, if i do setbylayer and then run this routine it doesn't work anymore on dynamic blocks.

The red cylinder is a dynamic block  which doesn't change back to color 200 after I run my lisp

(defun c:Atbk (/ doc b o SS blk)
  (vl-load-com)
  (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
  (vlax-for b (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object)))
    (if (/= (vl-string-elt (vla-get-name b) 0) 42)
      (vlax-for o b
        (vla-put-Color o 0) ;change all elements inside block to byblock
      )
    )
  )
  (if (setq SS (ssget "_X" '((0 . "INSERT"))))
    (foreach blk (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (setq blk (vlax-ename->vla-object blk))
      (vla-put-Color blk 200)
    )
  )
  (vla-regen doc acAllViewports)
  (princ)
)

 

immagine.thumb.png.a39f3f2a314caccf911a4dc3cebbc431.png

Posted

Try this:

(defun c:atbk (/ doc b o ss blk)
  (vl-load-com)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
    ;; (if	(/= (vl-string-elt (vla-get-name b) 0) 42)
    (vlax-for o	b
      (vla-put-color o 0)		;change all elements inside block to byblock
    )
    ;; )
  )
  (if (setq ss (ssget "_X" '((0 . "INSERT"))))
    (foreach blk (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
      (setq blk (vlax-ename->vla-object blk))
      (vla-put-color blk 200)
    )
  )
  (vla-regen doc acallviewports)
  (princ)
)

 

Posted

This worked for me in BrisCAD.  tho i didn't have any dynamic blocks. so it might be treating them as nested or anonymous?

 

(defun c:Atbk (/ blk doc obj SS)
  (vl-load-com)
  (vla-startundomark (setq doc (vla-get-activedocument (vlax-get-acad-object))))
  (vlax-for blk (vla-get-Blocks doc)
    (if (and (= (vla-get-isxref blk) :VLAX-FALSE)           ;ignores xrefs
             (not (wcmatch (vla-get-name blk) "*`**,*|*"))  ;ignores anonymous and xref blocks
        )
      (vlax-for obj blk
        (vla-put-Color obj 0) ;change all elements inside block to byblock
      )
    )
  )
  (if (setq SS (ssget "_X" '((0 . "INSERT"))))
    (foreach blk (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
      (vla-put-Color blk 200) ;added another mapcar to line above to convert at the list level from ename to vla-object
    )
  )
  (vla-regen doc acAllViewports)
  (vla-EndUndoMark doc)
  (princ)
)

 

Try this if it doesn't work.

Posted

thanks in advance! it works but not for the dimensions...must not change the color of the dimensions

 

immagine.png.48d7018e8fa7593b8923ef8e66f2d27a.png

Posted (edited)

thanks but not work with dynamic blocks

one more thing i would like to request please, could you also change the color of the groups to 142?

(chprop;group;*;;c;142;;^C^C)

Many thanks

Best regards

Edited by jim78b
Posted (edited)

your code is very fast than the other!  but it should keep the color of the dimensions and text outside the blocks...and could you also change the color of the groups to 142?

 

 

 

Immagine 2023-03-31 084300.png

Immagine 2023-03-31 084409.png

Edited by jim78b
Posted

I mean all inside block must be' chance color to byblock ...and the block outside change to my color 200. The text and dimensioni outside blocks don't be changed.  

 

Is beautiful if the routine can donthe same with groups...obiously group must be color 142

Posted

THERE IS A NESTED BLOCK, NO anonymous

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