PDA

View Full Version : Layer control in blocks



rwright.24150
2011-08-04, 04:59 PM
I'm not sure there is a solution for this, but maybe someone has a suggestion. I'm using Architecture 2011, but the problem is pretty generic.



I am working with a very complex vendor drawing and using it as an xref to my working drawing. I need to be able to freeze parts of the xref and change colors (for plotting purposes) of other parts. Under ideal circumstance this would require simple layer manipulation.



My problem is that a large percentage of the vendor drawing is made up of blocks. There are nearly 1000 different blocks. Most of these blocks were created using layers other than 0 - quite often more than one layer is used. Sometimes the block is inserted on a layer that was used in it's creation, sometimes not. The only way I can omit one of these blocks from my drawing is to figure out what layer was used in it's creation and freeze that layer. You can see how this could be a pretty tedious process.



My limited CAD knowledge only gives me 3 choices: 1) edit all 1000 blocks, changing them to layer 0, 2) shoot the drafter who created this mess (which is tempting), 3) shoot myself so someone else has to deal with it.



Anybody else have an idea?

cadtag
2011-08-04, 07:50 PM
SETBYLAYER command will handle option 1 quickly..

stelthorst
2011-08-04, 11:00 PM
Hi rwright,

I seem to remember a command in ACA that lets you do this easily but for the life of me can't remember it. I thought David Koch was the person who told me about it. Hopefully he'll read this and post it again. In the mean time take a look HERE (http://forums.augi.com/showthread.php?t=5547) and HER (http://forums.augi.com/showthread.php?t=23260)E and see if it helps.

Tom Beauford
2011-08-05, 11:43 AM
Try this:

; Written By: Tom Beauford
; Changes all block entities to layer "0" with color, linetype & lineweight ByBlock
(defun C:FIXBLKS (/ *ERROR* SSET intCount ENAM ELST BNAM FLST FIX1)
(setq thisdrawing (vla-get-activedocument (vlax-get-acad-object)))
(vla-startundomark thisdrawing)

(defun *ERROR* (err) ; define local handler
(vl-cmdf "undo" "Mark")
(princ "\n\n")
(princ)
); "" is the same message you get when exiting an AutoCAD command.
(defun FIX1 (BNAM / BENAM BONAM)
(if (not (member BNAM FLST))
(progn
(setq FLST (cons BNAM FLST)
BENAM (tblobjname "block" BNAM)
)
(while (setq BENAM (entnext BENAM))
(if (= (cdr (assoc 0 (entget BENAM))) "INSERT")
(fix1 (cdr (assoc 2 (entget BENAM))))
(progn
(setq BONAM(vlax-ename->vla-object BENAM))
(vl-catch-all-apply 'vla-put-layer (list BONAM "0"))
(vl-catch-all-apply 'vla-put-color (list BONAM 0))
(vl-catch-all-apply 'vla-put-linetype (list BONAM "Byblock"))
(vl-catch-all-apply 'vla-put-Lineweight (list BONAM -2))
; (vl-catch-all-apply 'vla-put-PlotStyleName (list BONAM "Byblock"))
)
)
)
)
)
)
(setq SSET (ssget (list (cons 0 "INSERT"))))
(repeat (setq intCount (sslength SSET))
(setq intCount (1- intCount)
ENAM (ssname SSET intCOunt)
ELST (entget ENAM)
BNAM (cdr (assoc 2 ELST))
FLST nil
)
(fix1 BNAM)
)
(vl-cmdf "regen")
(vla-endundomark thisdrawing)
(princ)
)

Careful, you may have some blocks that don't look right all the same color.