Jump to content

reset blocks within blocks to layer 0


ged

Recommended Posts

  • Replies 23
  • Created
  • Last Reply

Top Posters In This Topic

  • ged

    11

  • chulse

    6

  • David Bethel

    3

  • Strix

    2

Top Posters In This Topic

Thanks Cary for the reply,

I have used this lisp before but it only goes down 1 layer and not blocks within blocks. We receive a lot of different architects drawings from differing sources and would like to colour them all 252 in 1 swoop. The problem is that some of the blocks are not on layer 0 when they are made, therefore they retain their colour and layer name. We then xref this drawing into another drawing and simply draw over the top with our building service symbols. It sounds simple but we spend lots of time cleaning architects drawings up and revision after revision, its a complete waste of time and resources. Its driving me crazy!!:shock:

Link to comment
Share on other sites

thread moved - thanks for the PM :thumbsup:

 

PS - 'mod' is too short to come up on a forum search so we can't pick messages up on thread by that method :(

 

Gotcha!

 

Thanks

Link to comment
Share on other sites

yep - and if you set your CP to send you emails for subscribed threads you won't have to hang around, you can work on something else :wink:

 

I've given you a more specific title too :thumbsup:

Link to comment
Share on other sites

Totally untested and "AS IS", Even if it blows up your dwg.

 

Change ALL nested INSERTs to LAyer 0

 

(defun c:nestb2lay0 (/ tdef fe fd)
 (while (setq tdef (tblnext "BLOCK" (not tdef)))
        (setq fe (cdr (assoc -2 tdef)))
        (while fe
           (setq fd (entget fe))
           (and (= "INSERT" (cdr (assoc 0 fd)))
                (/= "0" (cdr (assoc 8 fd)))
                (entmod (subst '(8 . "0") (assoc 8 fd) fd)))
           (setq fe (entnext fe))))
 (prin1))

-David

Link to comment
Share on other sites

Hi again David,

I gave the lisp a go but cant get it to function using any of the methods for loading lisp files, any ideas. I'm using cad 2006, does that make a difference?

Link to comment
Share on other sites

I've found something which may be of use to others, not tried it yet but it looks promising, the comand is "nuke"

 

(defun To-0( BLCK / BNAME BLIST E EDATA SPIN TMP )

;;; Prints a pinwheel on the command line
(defun Spin ( )
(setq SYM 
(cond 
((= SYM nil) "-")
((= SYM "-") "\\")
((= SYM "\\") "|")
((= SYM "|") "/")
((= SYM "/") "-")
)
)
(princ (strcat "\rScanning... " SYM " "))
);end spin

(if (=(type BLCK)(read "LIST"))(setq TMP(car BLCK) BLIST(cdr BLCK) BLCK TMP TMP nil))
(setq BLCK(tblsearch "BLOCK" BLCK))
(if 
(and
(/=(logand(cdr(assoc 70 BLCK))1)1) ;skips annomyous blocks
(/= (logand(cdr(assoc 70 BLCK))4)4) ;skips xrefs
);and
(progn
(setq E (cdr (assoc -2 BLCK)))
(while E
(if (=(cdr(assoc 0 (entget E))) "INSERT") ;If the object is a block
(progn
(setq BNAME(cdr(assoc 2(entget E)))) ;save the name to a list
(if (not (member BNAME BLIST))
(if (not BLIST)(setq BLIST (list BNAME)) ;create the list if it doesn't exist
(setq BLIST(append BLIST(list BNAME)))
);if
);if
);progn 
);if
(setq EDATA (entget E))
(if(assoc 62 EDATA) ;Resets object color to BYLAYER if it isn't.
(setq EDATA(subst(cons 62 256)(assoc 62 EDATA)EDATA))
);if
(if(assoc 6 EDATA) ;Resets object linetype to BYLAYER if it isn't.
(setq EDATA(subst(cons 6 "BYLAYER")(assoc 6 EDATA)EDATA))
);if
(setq EDATA(subst (cons 8 "0")(assoc 8 EDATA)EDATA));changes layer to 0
(entmod EDATA);updates entity
(setq E (entnext E));get next enitiy, nil if end of block
(Spin)
);end while E
);progn
);if
BLIST; returns names of any nested blocks
);defun


(defun C:NUKE( / BLK_NM CHOICE E EDATA IDX PK_BLK SS)
(command "._undo" "m")
(setq CHOICE "S")
(initget "G S")
(setq CHOICE(getkword (strcat "\n<G>lobal or <S>elect block: <" CHOICE "> ")))
(if(not CHOICE)(setq CHOICE "S"))
(if (= (strcase CHOICE) "G")
;global nuke
(while (setq BLK_NM(tblnext "BLOCK" (null BLK_NM)))
(TO-0 (cdr(assoc 2 BLK_NM)))
);while
;nuke selected block
(progn
(prompt "\nSelect Block(s) to Nuke: ")
(setq SS(ssget '((0 . "INSERT"))))
(setq IDX 0)
(repeat (sslength SS)
(setq BLK(cdr(assoc 2 (entget(ssname SS IDX)))))
(cond
(PK_BLK (setq PK_BLK(append PK_BLK (list BLK))))
(T (setq PK_BLK(list BLK)))
);cond
(setq IDX(1+ IDX))
);repeat
(while PK_BLK
(setq PK_BLK(To-0 PK_BLK))
);while
);progn
);if
(command "._regen")
(princ "\rFinished ")
(princ)
);defun
(prompt"\nNUKE loaded.")(princ)

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