Does anyone have a lisp that will search a drawing and list each layer that the block has in it. The lisp needs to specify the block name and the list of layers.
|
Does anyone have a lisp that will search a drawing and list each layer that the block has in it. The lisp needs to specify the block name and the list of layers.
Do you mean "list each layer that has a block in it"?
No. Becasue most blocks that I have were created with the layers already in them. So I am trying to get them to be set to a standard of being on layer 0.
Thank you
How about this? It's not stylish, and simply prints the layer names:
Code:;;; BLOCK_LAYERS (defun c:block_layers ( / myblock tlist ename llist ctr) (while (setq myblock (car (entsel "\nSelect a block: "))) (if (= (cdr (assoc 0 (entget myblock))) "INSERT") (progn (setq tlist (tblsearch "BLOCK" (cdr (assoc 2 (entget myblock)))) ename (cdr (assoc -2 tlist)) ) (while ename (if llist (setq llist (append (list (cdr (assoc 8 (entget ename)))) llist) ) (setq llist (list (cdr (assoc 8 (entget ename))))) ) (setq ename (entnext ename)) ) (setq ctr 0) (princ(strcat "\nBlock " (cdr (assoc 2 (entget myblock))))) (repeat(length llist) (princ(strcat "\n" (nth ctr llist))) (setq ctr(1+ ctr)) ) ) (if myblock (princ "\nObject is not a block. ") ) ) ) (princ) )
Last edited by lance.81922; 2005-05-06 at 06:45 PM.
You're welcome. You could avoid duplicate layer names in llist by checking to see if the layer name was already a member:DOH! Shoulda thought of that when I wrote it.Code:(if(not(member(cdr (assoc 8 (entget ename)))llist)) (setq llist(append(cdr (assoc 8 (entget ename))) llist)) )
Last edited by lance.81922; 2005-05-06 at 07:44 PM.
I though the request was to set all objects in the block to zero?
If so http://www.theswamp.org/phpBB2/viewt...light=fixblock
No, the original request wasI guess he wanted to display exactly which layers the user(s) had put into the block.Does anyone have a lisp that will search a drawing and list each layer that the block has in it. The lisp needs to specify the block name and the list of layers.
Sorry Lance, I must have misunderstood the request when I saw this.
I read this as a clarification of the request which was something totally different.Originally Posted by bnc_designs
Perhaps Brad was just rambling at this point in the thread.
My take on this is to respond to the original request, and/or to ask for clarification of that request. You're not wrong, ab2draft, you just saw something different than what I saw. It's certainly true that FIXBLOCK (and utilities that I, and doubtless a zillion others, have written) will move all the objects in a block to layer 0, thus gaining for it (the block) the ability to take on the characteristics of the layer on which it's inserted. I just figured that if bnc_designs wanted a program to do that, he/she would have said so.
It does seem logical to change the blocks over -- I agree. It's just that different users (our AutoLISP "customers") have different ideas of how to accomplish their goals. I figure it's MY job, as a programmer, to give them what they ask for. Then, if they realize that what they asked for is not what they really want, I just adjust to suit. Sort of a "be careful what you ask for because you just might get it" philosophy.
Just my $0.02 (adjusted for inflation).
Lance