Strange Block Insertion Issue

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
happen.
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.
Bruce
Reply to
Mr. B
Loading thread data ...
I suggest that you post a drawing, so we can have a look, and maybe a solution.....
"Mr. B" a écrit :
Reply to
Michel
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.
Regards,
Bruce
Reply to
Mr. B
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.
Regards,
Bruce PKÎX/pÏ&8©FrÆA2.1.dxfí}[?Ü8²æ{õü°»èIQõ¨T*í?NWÕV?û2/?§Û3ÇX»ÑãÞ?ÆÁü÷%)Râ]Ô%«Ê3d???? ?Á2øéöâ¸úæ??7W?x?®¾yÕ5?î?ÿ¨¯¾ùMÛ¾ï«o?Xêe¯??? ¼?ÑaEpøáe{{è?Ï*X7çë·?H?\?÷?CÆv¼4?Ù î~|x}}#i!dW` 0©h?ëRrR?w¢u X ¤e)ëù?U4$®©^oó£ªÃrW()%??¬?í(ª???âi Õ%Qµ?®_?ÒÚ=(?v1iP]?T·÷¯n_3=j:æ??Þw/»?`éñút þïÞq«thöõõý='ð?Îms?«f¶ypjÚãµ?¯ÿ¬¸Ðn°¤?û¦í~¸>¸õ ???DS/ØP?¿¼ûô?ß~Qåí©ù©7O6??ÞîO??CiwzøéNð²aÙÿqz÷ÇûßÆÂöötËy?0Çh;Îèááú|w¾>½òêåpý:Èöº9ÿÙí:Ëï~¼?ù`G?^r8]?bWé÷7?? ?7¿ûqÉhááÎKÿð?-ÌÁíAÛÝxó?[õ?Bêc>*z¸*ýá6
Reply to
Mr. B
Well... that didn't work (:
I've a small ZIP file I've tried to attached. But my Server doesn't like it :(
Unless you want me to email you this zip file... then alas.
Bruce
Reply to
Mr. B
Bruce, 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?
Jeff
Reply to
Jeff
I'm using AC2002 LT.
'Cause I HATE it when people 'force' linetypes and colours when I use them as backgrounds (ie: I like to be able to control colours, etc.).
Regards,
Bruce
Reply to
Mr. B
The weird behavior is because of the conversion.....try this Lisp instead
(defun C:X ( / ) (setvar "cmdecho" 0) (setq FirstBlockDefinition (tblnext "BLOCK" t)) (while FirstBlockDefinition (setq Bname (cdr (assoc 2 FirstBlockDefinition))) (setq Def (tblobjname "BLOCK" Bname)) (setq NextItem (entnext Def)) (while NextItem (setq DxfCode (entget NextItem)) (setq DxfCode (subst (cons 62 256) (assoc 62 DxfCode) DxfCode)) (setq DxfCode (subst (cons 6 "bylayer") (assoc 6 DxfCode) DxfCode)) (setq DxfCode (subst (cons 8 "0") (assoc 8 DxfCode) DxfCode)) (entmod DxfCode) (setq NextItem (entnext NextItem)) ) (entupd def) (setq FirstBlockDefinition (tblnext "BLOCK")) ) (princ) )
"Mr. B" a écrit :
Reply to
Michel
They this Lisp code - I can't remember where I found it from originally:
Matthew
__________________________________
; NUKE.LSP redefines all objects in a block on layer 0, with color and linetype ; set to BYLAYER. NUKED blocks will then take on the properties of the layer ; that they are inserted on. The routine works by modifing objects in the block table, ; so the blocks never have to be exploded. ; ; The global method redefines ALL objects in every block in the current drawing, ; 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 method, ; 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 ( ) (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 "\nlobal or elect block: "))) (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 (princ)
Reply to
Matthew Taylor
Yeah... it'd be nice to know 'why'...
Verrryy nice and slick. The only thing needed was to add a 'regen' command at the end.
Thanks Muchly. I'm going to modify my original LSP file with this.
Regards,
Bruce
Reply to
Mr. B
Hmmm... Interesting... Works just as well.... Thanks!
Bruce
Reply to
Mr. B

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.