When I get a background (in DXF format) from anyone having a non-PC
non-Autocad 'cad' package (ie: MAC user) and I create the DWG file, you end up
getting lots of blocks, etc. But this because of the DXF, all the blocks are
hard coded with linetypes, colours, layers. Which I don't like. So...
I've a LISP routine to search through the data base to take each block one at
a time and:
Change Linetype: bylayer
Change Colour: bylayer
Change Layer: 0 (zero)
Then it redefines the block (using the blocks original insert point).
BUT, here is what happens... when the block is redefined, the block physically
is located in a different location on the drawing... even though the insert
point IS correct.
I've looked at all the Setvar's, properties, Osnaps, USC, elevations, etc.
But can't see anything weird.
Even if I cut/paste one of his blocks on a new drawing, the same thing will
NOW... If I manually explode his block, change the properties, then redefine
the block, it is OK. This is using the popup BLOCK menu.
IF I manually define the block using the -block command (ie: no menu), and
then manually insert the file ( -insert ), the same weird insert happens.
Anyone KNOW what the hell is going on? It's only with these MAC DXF files
that this seems to happen to.
Thanks in advance.
Okay... here is a 'section' of the drawing in question (one of many). And
I've attached a quick LSP file (X.lsp) to show you how the redefining of the
block goes strange.
The LSP file gets the current block insert point. Explodes the block and
changes the block properties (line type, colour, etc). Then redefines the
exploded enties using the original block name and insert point (-block).
Then attempts to insert the block in the SAME insert point (inspt variable).
But you'll see it inserts the block in a different location... EVEN though the
insert point IS correct.
Something happens during the redefining.
You can do this manually and get the same results as long as you do NOT use
the popup Block window. (-block and -insert). IF you DO use the popups, then
things are OK. But with hundreds of blocks... alas, not an option.
Feel free to email these to me and I will take a look, provided you are NOT
using AC2004. But as an aside, rather than exploding/redefining/re-inserting
all these blocks, why not change the data that needs to be changed in the
block definition itself?
They this Lisp code - I can't remember where I found it from originally:
; NUKE.LSP redefines all objects in a block on layer 0, with color and
; set to BYLAYER. NUKED blocks will then take on the properties of the
; that they are inserted on. The routine works by modifing objects in the
; so the blocks never have to be exploded.
; The global method redefines ALL objects in every block in the current
; except dimensions, hatching or xrefs, even if they are on a layer that is
; frozen or turned off.
; The select method redefines blocks selected with any standard selection
; as well as any blocks nested in the selected block(s).
(defun To-0( BLCK / BNAME BLIST E EDATA SPIN TMP )
;;; Prints a pinwheel on the command line
(defun Spin ( )
((= SYM nil) "-")
((= SYM "-") "\\")
((= SYM "\\") "|")
((= SYM "|") "/")
((= SYM "/") "-")
(princ (strcat "\rScanning... " SYM "
(if (=(type BLCK)(read "LIST"))(setq TMP(car BLCK) BLIST(cdr BLCK) BLCK
TMP TMP nil))
(setq BLCK(tblsearch "BLOCK" BLCK))
(/=(logand(cdr(assoc 70 BLCK))1)1) ;skips annomyous blocks
(/= (logand(cdr(assoc 70 BLCK))4)4) ;skips xrefs
(setq E (cdr (assoc -2 BLCK)))
(if (=(cdr(assoc 0 (entget E))) "INSERT") ;If the object is a
(setq BNAME(cdr(assoc 2(entget E)))) ;save the name to a
(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)))
(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(assoc 6 EDATA) ;Resets object linetype to BYLAYER if it
(setq EDATA(subst(cons 6 "BYLAYER")(assoc 6 EDATA)EDATA))
(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
);end while E
BLIST; returns names of any nested blocks
(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 "\nlobal or elect block:
(if(not CHOICE)(setq CHOICE "S"))
(if (= (strcase CHOICE) "G")
(while (setq BLK_NM(tblnext "BLOCK" (null BLK_NM)))
(TO-0 (cdr(assoc 2 BLK_NM)))
;nuke selected block
(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)))))
(PK_BLK (setq PK_BLK(append PK_BLK (list BLK))))
(T (setq PK_BLK(list BLK)))
(setq IDX(1+ IDX))
(setq PK_BLK(To-0 PK_BLK))
(princ "\rFinished ")
Yeah... it'd be nice to know 'why'...
Verrryy nice and slick. The only thing needed was to add a 'regen' command at
Thanks Muchly. I'm going to modify my original LSP file with this.