Jump to content

Looking for a Lisp routine


tzframpton

Recommended Posts

Anyone have a routine that can grab all blocks, and set the contents inside the block to By Layer for the color? sometimes i get drawings and there might be, say, 150 doors as blocks, but there's like 75 different door names, so i constantly use QSELECT and explode, highlight all, then set the color By Layer. Just seeing if there was a Lisp routine out there that can do that....

 

although i'm not sure if/how this can work, due to the standard way about doing this is using REFEDIT. anyways, just seeing if there's something out there that anyone has. Anything will be greatly appreciated. Thanks in advance 8)

Link to comment
Share on other sites

  • Replies 37
  • Created
  • Last Reply

Top Posters In This Topic

  • tzframpton

    6

  • designerstuart

    6

  • Lee Mac

    4

  • irneb

    3

Top Posters In This Topic

Posted Images

Guest Alan Cullen

Say no more, mate.......

 

architects !!!!! sorry all you architects.....

 

Styk.....tell me a bit more....I may be able to help.....??? :)

Link to comment
Share on other sites

Alan, you're unbanned!! nice to have you back... 8)

 

well, basically what i'm wanting is this: a routine that selects all blocks in the drawing, and changes the color to By Layer. not the block itself, but the contents inside the block. is this possible via Lisp? EDIT: i'm trying to get away from exploding all the blocks, this is why i'm asking about a program that can do such a thing.

Link to comment
Share on other sites

Try it

;;published by kpblc
;;http://www.arcada.com.ua/forum/viewtopic.php?t=526
(defun c:normblocks (/ adoc answer lays lock lay *error* ans0 atype cnt) 
(defun *error* (msg)(princ msg)
  (if lock (foreach x lock (vla-put-lock x :vlax-true)))(vl-cmdf "_.Redraw")) 
 (vl-load-com)(setq cnt 0) 
 (setq adoc (vla-get-activedocument (vlax-get-acad-object))) 
 (setq lays (vla-get-layers adoc)) 
 (vla-startundomark adoc) 
 (initget "LType LWeight Color All _ T W C A") 
 (if (null (setq answer 
     (getkword "\nIn blocks to lead to norm [LType/LWeight/Color/All] <All> : ")))
   (setq answer "A")) ;_ end of if
 (initget "byLayer byBlock")
 (setq atype (getkword "\nSet contents inside the block to [byLayer/byBlock] <byBlock>:"))
 (initget "Yes No")
 (setq ans0 (getkword "\nChange entities layer's to 0? [Yes/No] <No>:"))
 (vlax-for item (vla-get-blocks adoc) 
   (if   (not (wcmatch (strcase (vla-get-name item) t) "*_space*"))
     (progn
     (setq cnt (1+ cnt))
     (grtext -1 (strcat "Modyfied " (vla-get-name item)))
  (vlax-for   sub_item (vla-item (vla-get-blocks adoc) (vla-get-name item)) 
  (setq lay (vla-item lays (vla-get-layer sub_item))) 
  (if (= (vla-get-lock lay) :vlax-true) 
  (progn (vla-put-lock lay :vlax-false)(setq lock (cons lay lock))))  
  (if (= ans0 "Yes")(vla-put-Layer sub_item "0"))
  (cond 
    ((= answer "W") 
     (vla-put-LineWeight sub_item (if (= atype "byLayer") acLnWtByLayer aclnwtbyblock))
     ) 
    ((= answer "T") 
     (vla-put-linetype sub_item (if (= atype "byLayer") "ByLayer" "ByBlock"))
     ) 
    ((= answer "C") 
     (vla-put-color sub_item (if (= atype "byLayer") acByLayer acByBlock))
     ) 
    (t 
     (vla-put-LineWeight sub_item (if (= atype "byLayer") acLnWtByLayer aclnwtbyblock))
     (vla-put-linetype sub_item (if (= atype "byLayer") "ByLayer" "ByBlock"))      
     (vla-put-color sub_item (if (= atype "byLayer") acByLayer acByBlock))
     ) 
    ) ;_ end of cond 
  ) ;_ end of vlax-for
  )
     ) ;_ end of if 
   ) ;_ end of vlax-for 
 (if lock (foreach x lock (vla-put-lock x :vlax-true))) 
 (vla-regen adoc acallviewports) 
 (vla-endundomark adoc)(vl-cmdf "_.Redraw")
 (princ (strcat  "\nModyfied " (itoa cnt) " blocks"))
 (princ) 
 ) ;_ end of defun 

Link to comment
Share on other sites

VVA, I would like to say that you are the MAN!! works Perfectly.... wow, that saves loads of time. it even has more options, like setting all contents to layer 0.

 

Thanks a bunch!! i noticed it was written by kpblc, which is on this forum... so a big thanks to him if he is the author.

 

8)

Link to comment
Share on other sites

Yes, the beginning to it was put by Alexey (kpblc). I have only a little improved.

*** Added ***

It seems to me architects in all countries are identical. This routine was written for change of their drawings

Link to comment
Share on other sites

Guest Alan Cullen

Hey Styk.......you definitely got the response you were after very quickly...good. :D

 

VVA...I do not have a problem with architects, my brother and my sister-in-law are both architects.....so I do not hold that against them.

 

However....they do make life for us pleds much harder....:lol:

Link to comment
Share on other sites

I have just the routine for you (free) here:

http://paracadd.com

Look for BLKCOLT.LSP

 

Anyone have a routine that can grab all blocks, and set the contents inside the block to By Layer for the color? sometimes i get drawings and there might be, say, 150 doors as blocks, but there's like 75 different door names, so i constantly use QSELECT and explode, highlight all, then set the color By Layer. Just seeing if there was a Lisp routine out there that can do that....

 

although i'm not sure if/how this can work, due to the standard way about doing this is using REFEDIT. anyways, just seeing if there's something out there that anyone has. Anything will be greatly appreciated. Thanks in advance 8)

Link to comment
Share on other sites

I'd like to talk abount "ByLayer" settings inside the block definitions. Usually i've setting all "ByBlock" - it makes block using more flexible :) Look at the attachment :)

File created at ADT2005Eng, so file could contains some garbage.

blocks.zip

Link to comment
Share on other sites

I'd like to talk abount "ByLayer" settings inside the block definitions. Usually i've setting all "ByBlock" - it makes block using more flexible :) Look at the attachment :)

File created at ADT2005Eng, so file could contains some garbage.

kpblc, that is a really good discription on how it works via ByLayer & ByBlock. Honestly, I never knew exactly the difference between the two, but now that i do it makes more sense. Thanks for that little lesson on layer control for blocks.... 8)

 

- Tannar

Link to comment
Share on other sites

There are good uses for both methods; however, the most important consideration in my work (civil site, municipal utilities) is that the color and linetype can be reassigned to anything that is xreferenced. The one critical requirement for this is that the entities have BYLAYER for their color and linetype. If they do not then I'm stuck with whatever color and linetype they have in the original drawing. This is true for your example as well. To see what I mean xreference it and change all of the layer colors to something different. The BYBLOCK colors remain unchanged but all of the others take on the new color. In my work I need them to be able to take on a new color (and linetype).

Link to comment
Share on other sites

  • 2 years later...

Years ago I wrote a VBA routine that performs the "All Colors ByLayer" portion of this routine. Of course I worked at another company and didn't manage to make a copy of the code. So rather than rewriting it this is a really nice piece of code!!!

Link to comment
Share on other sites

Anyone have a routine that can grab all blocks, and set the contents inside the block to By Layer for the color? sometimes i get drawings and there might be, say, 150 doors as blocks, but there's like 75 different door names, so i constantly use QSELECT and explode, highlight all, then set the color By Layer. Just seeing if there was a Lisp routine out there that can do that....

 

although i'm not sure if/how this can work, due to the standard way about doing this is using REFEDIT. anyways, just seeing if there's something out there that anyone has. Anything will be greatly appreciated. Thanks in advance 8)

 

Try _setbylayer command or go to your pulldown menu under modify and click Change to ByLayer.

Link to comment
Share on other sites

Try _setbylayer command or go to your pulldown menu under modify and click Change to ByLayer.

 

 

_setbylayer is a great command!

That does exactly what I need.

 

...Modify, Change to ByLayer does not appear to be available in my menus using AutoCAD 2010.

Link to comment
Share on other sites

_setbylayer is a great command!

That does exactly what I need.

 

...Modify, Change to ByLayer does not appear to be available in my menus using AutoCAD 2010.

 

I am using 2009, So I am not sure where it would be in 2010. Your best bet is to look up _setbylayer command in the ACAD help section to see where it would reside in the pulldown menu area.

Link to comment
Share on other sites

I am using 2009, So I am not sure where it would be in 2010. Your best bet is to look up _setbylayer command in the ACAD help section to see where it would reside in the pulldown menu area.

 

 

 

If you're lazy like me, you may like this...

 

http://www.cadtutor.net/forum/showthread.php?p=271416&highlight=setbylayer#post271416

Link to comment
Share on other sites

_setbylayer is a great command!

That does exactly what I need.

 

...Modify, Change to ByLayer does not appear to be available in my menus using AutoCAD 2010.

 

A lisp routine to do automatically as setbylayer but to blocks only (redefine all blocks' properties to bylayer without prompt) is BL02.lsp--- attached

BL02.LSP

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