tzframpton Posted April 27, 2007 Posted April 27, 2007 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 Quote
DANIEL Posted April 27, 2007 Posted April 27, 2007 sounds like you need to standardize your blocks Quote
tzframpton Posted April 27, 2007 Author Posted April 27, 2007 not my blocks... these are drawings from the architects.... :wink: Quote
Guest Alan Cullen Posted April 27, 2007 Posted April 27, 2007 Say no more, mate....... architects !!!!! sorry all you architects..... Styk.....tell me a bit more....I may be able to help.....??? Quote
tzframpton Posted April 27, 2007 Author Posted April 27, 2007 Alan, you're unbanned!! nice to have you back... 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. Quote
VVA Posted April 27, 2007 Posted April 27, 2007 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 Quote
tzframpton Posted April 27, 2007 Author Posted April 27, 2007 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. Quote
VVA Posted April 27, 2007 Posted April 27, 2007 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 Quote
Guest Alan Cullen Posted April 27, 2007 Posted April 27, 2007 Hey Styk.......you definitely got the response you were after very quickly...good. 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.... Quote
Paraglide1 Posted April 27, 2007 Posted April 27, 2007 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 Quote
kpblc Posted April 28, 2007 Posted April 28, 2007 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 Quote
tzframpton Posted April 28, 2007 Author Posted April 28, 2007 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.... - Tannar Quote
Paraglide1 Posted April 28, 2007 Posted April 28, 2007 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). Quote
fryeguy Posted February 17, 2010 Posted February 17, 2010 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!!! Quote
The Buzzard Posted February 18, 2010 Posted February 18, 2010 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 Try _setbylayer command or go to your pulldown menu under modify and click Change to ByLayer. Quote
fryeguy Posted February 18, 2010 Posted February 18, 2010 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. Quote
The Buzzard Posted February 18, 2010 Posted February 18, 2010 _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. Quote
alanjt Posted February 18, 2010 Posted February 18, 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. If you're lazy like me, you may like this... http://www.cadtutor.net/forum/showthread.php?p=271416&highlight=setbylayer#post271416 Quote
gilsoto13 Posted February 18, 2010 Posted February 18, 2010 _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 Quote
Recommended Posts
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.