TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: AVCAD on October 09, 2007, 10:50:20 AM

Title: Bursting a previously inserted block?
Post by: AVCAD on October 09, 2007, 10:50:20 AM
Is there away to burst a block right after you insert it. The Select previous command doesn't work very well and usually selects the object you had selected before you inserted the block.

I am sure there is just a function I don't know.

I am on ACAD 2006.

Thanks in advance.
Title: Re: Bursting a previously inserted block?
Post by: AVCAD on October 09, 2007, 10:53:51 AM
just a side question cause I am working on something right now with fields.....

Fieldeval = 31

what is 31????

I know there are

0 - not updated
1 - update on open
2 - update on save
4 - update on plot
8 - update on etransmit
16 - updated on regen

but there is no definition for 31 and thats the default value of that variable

thanks again.
Title: Re: Bursting a previously inserted block?
Post by: LE on October 09, 2007, 10:55:30 AM
(+ 0 1 2 4 8 16) = ?

:)
Title: Re: Bursting a previously inserted block?
Post by: AVCAD on October 09, 2007, 11:07:27 AM
(+ 0 1 2 4 8 16) = ?

:)

OWNED BY LOGIC....  :ugly:
Title: Re: Bursting a previously inserted block?
Post by: LE on October 09, 2007, 11:17:00 AM
Is there away to burst a block right after you insert it. The Select previous command doesn't work very well and usually selects the object you had selected before you inserted the block.

I am sure there is just a function I don't know.

I am on ACAD 2006.

Thanks in advance.

Use 'Last'

Quote
Command: burst
Select objects: L
1 found
Select objects:
/
Title: Re: Bursting a previously inserted block?
Post by: Bred on October 09, 2007, 11:19:03 AM
Hello
*myblock ?
Title: Re: Bursting a previously inserted block?
Post by: daron on October 09, 2007, 11:20:41 AM
Is there away to burst a block right after you insert it. The Select previous command doesn't work very well and usually selects the object you had selected before you inserted the block.

I am sure there is just a function I don't know.

I am on ACAD 2006.

Thanks in advance.

Use 'Last'

Quote
Command: burst
Select objects: L
1 found
Select objects:
/

Just be careful to make sure that that particular object is visible on the screen, otherwise you'll end up with the same problem you had to begin with.
Title: Re: Bursting a previously inserted block?
Post by: T.Willey on October 09, 2007, 11:22:05 AM
I would use ' (entlast) ' incase the block is off screen, otherwise use what Luis posted.  Just tested, can not be used, as burst is a lisp routine.  I think I wrote a burst routine here somewhere.  So I would go with what Luis said.

Daron beat me to the waring, but I'm still posting!
Title: Re: Bursting a previously inserted block?
Post by: LE on October 09, 2007, 11:24:35 AM
Just be careful to make sure that that particular object is visible on the screen, otherwise you'll end up with the same problem you had to begin with.

I must have other kind of powers, because here I can do that.... and works :)
Title: Re: Bursting a previously inserted block?
Post by: AVCAD on October 09, 2007, 11:26:15 AM
the "last" option might not work always but the entlast would

So can i just write a small lisp to select the last object using entlast, load it through a button and then use the burst command?

I know burst wont work through lisps...not really sure why though but its been like that since forever.
Title: Re: Bursting a previously inserted block?
Post by: T.Willey on October 09, 2007, 11:30:45 AM
You can try the routine here [> LINK <] (http://www.theswamp.org/index.php?topic=18341.0).
Title: Re: Bursting a previously inserted block?
Post by: ronjonp on October 09, 2007, 11:38:14 AM
You could also insert blocks using the tool palette and set the explode option to yes:

(http://www.theswamp.org/screens/index.php?dir=ronjonp/&file=toolpalletexplode.png)
Title: Re: Bursting a previously inserted block?
Post by: LE on October 09, 2007, 11:40:07 AM
now, I am all confused..... are you guys talking about explode or the burst command?
Title: Re: Bursting a previously inserted block?
Post by: T.Willey on October 09, 2007, 11:46:36 AM
now, I am all confused..... are you guys talking about explode or the burst command?
Should be burst.  Explode won't keep the attribute information, so I would think that explode is a no go.
Title: Re: Bursting a previously inserted block?
Post by: AVCAD on October 09, 2007, 11:53:32 AM
ya no explode.

I actually wish Autodesk would just get rid of that command. But then how would you fix those lovely proxy images with embedded colors from arch desktop....oh wait i know use bylayer instead of embedding colors...oops..i should probably head over to the vent thread...
Title: Re: Bursting a previously inserted block?
Post by: Joe Burke on October 10, 2007, 09:08:00 AM
Of course the downside of relying on burst is it's an ET command. Which may not be loaded or whatever...

It's not difficult to convert attributes to text using explode. That's what I do within the SuperFlatten routine.
Title: Re: Bursting a previously inserted block?
Post by: KewlToyZ on October 10, 2007, 10:34:03 AM
I just use an old copy of burst that automatically selects all, thanks to CAB showing me how to do it.
Placed it into my support directory. The only reason is I can retain some objects like fixtures etc... while removing bound blocks of entire rooms. I just set the number of times to run the routine depnding on how nested the XREF's were before binding when I setup the background files.

Code: [Select]
(Defun C:MYBURST (/ item bitset bump att-text lastent burst-one burst
                  BCNT BLAYER BCOLOR ELAST BLTYPE ETYPE PSFLAG ENAME )
 
   ;-----------------------------------------------------
   ; Item from association list
   ;-----------------------------------------------------
   (Defun ITEM (N E) (CDR (Assoc N E)))
   ;-----------------------------------------------------
   ; Error Handler
   ;-----------------------------------------------------
 
  (acet-error-init
    (list
      (list "cmdecho" 0
            "highlight" 1
      )
      T     ;flag. True means use undo for error clean up.
    );list
  );acet-error-init
 
 
   ;-----------------------------------------------------
   ; BIT SET
   ;-----------------------------------------------------
 
   (Defun BITSET (A B) (= (Boole 1 A B) B))
 
   ;-----------------------------------------------------
   ; BUMP
   ;-----------------------------------------------------
 
   (Setq bcnt 0)
   (Defun bump (prmpt)
      (Princ
         (Nth bcnt '("\r-" "\r\\" "\r|" "\r/"))
      )
      (Setq bcnt (Rem (1+ bcnt) 4))
   )
 
   ;-----------------------------------------------------
   ; Convert Attribute Entity to Text Entity
   ;-----------------------------------------------------
 
   (Defun ATT-TEXT (AENT / TENT ILIST INUM)
      (Setq TENT '((0 . "TEXT")))
      (ForEach INUM '(8
            6
            38
            39
            62
            67
            210
            10
            40
            1
            50
            41
            51
            7
            71
            72
            73
            11
            74
         )
         (If (Setq ILIST (Assoc INUM AENT))
            (Setq TENT (Cons ILIST TENT))
         )
      )
      (Setq
         tent (Subst
                 (Cons 73 (item 74 aent))
                 (Assoc 74 tent)
                 tent
              )
      )
      (EntMake (Reverse TENT))
   )
 
   ;-----------------------------------------------------
   ; Find True last entity
   ;-----------------------------------------------------
 
   (Defun LASTENT (/ E0 EN)
      (Setq E0 (EntLast))
      (While (Setq EN (EntNext E0))
         (Setq E0 EN)
      )
      E0
   )
 
   ;-----------------------------------------------------
   ; See if a block is explodable. Return T if it is,
   ; otherwise return nil
   ;-----------------------------------------------------
 
   (Defun EXPLODABLE (BNAME / B expld)
      (setq BLOCKS (vla-get-blocks
                     (vla-get-ActiveDocument (vlax-get-acad-object)))
       )
     
      (vlax-for B BLOCKS (if (and (= :vlax-false (vla-get-islayout B))
                                  (= (strcase (vla-get-name B)) (strcase BNAME)))
                      (setq expld (= :vlax-true (vla-get-explodable B)))
           )
       )
       expld
    )


   ;-----------------------------------------------------
   ; Burst one entity
   ;-----------------------------------------------------
 
   (Defun BURST-ONE (BNAME / BENT ANAME ENT ATYPE AENT AGAIN ENAME
                     ENT BBLOCK SS-COLOR SS-LAYER SS-LTYPE mirror ss-mirror
                     mlast)
      (Setq
         BENT   (EntGet BNAME)
         BLAYER (ITEM 8 BENT)
         BCOLOR (ITEM 62 BENT)
         BBLOCK (ITEM 2 BENT)
         BCOLOR (Cond
                   ((> BCOLOR 0) BCOLOR)
                   ((= BCOLOR 0) "BYBLOCK")
                   ("BYLAYER")
                )
         BLTYPE (Cond ((ITEM 6 BENT)) ("BYLAYER"))
      )
      (Setq ELAST (LASTENT))
      (If (and (EXPLODABLE BBLOCK) (= 1 (ITEM 66 BENT)))
         (Progn
            (Setq ANAME BNAME)
            (While (Setq
                      ANAME (EntNext ANAME)
                      AENT  (EntGet ANAME)
                      ATYPE (ITEM 0 AENT)
                      AGAIN (= "ATTRIB" ATYPE)
                   )
               (bump "Converting attributes")
               (ATT-TEXT AENT)
            )
         )
      )
         (Progn
            (bump "Exploding block")
            (acet-explode BNAME)
            ;(command "_.explode" bname)
         )
      (Setq
         SS-LAYER (SsAdd)
         SS-COLOR (SsAdd)
         SS-LTYPE (SsAdd)
         ENAME    ELAST
      )
      (While (Setq ENAME (EntNext ENAME))
         (bump "Gathering pieces")
         (Setq
            ENT   (EntGet ENAME)
            ETYPE (ITEM 0 ENT)
         )
         (If (= "ATTDEF" ETYPE)
            (Progn
               (If (BITSET (ITEM 70 ENT) 2)
                  (ATT-TEXT ENT)
               )
               (EntDel ENAME)
            )
            (Progn
               (If (= "0" (ITEM 8 ENT))
                  (SsAdd ENAME SS-LAYER)
               )
               (If (= 0 (ITEM 62 ENT))
                  (SsAdd ENAME SS-COLOR)
               )
               (If (= "BYBLOCK" (ITEM 6 ENT))
                  (SsAdd ENAME SS-LTYPE)
               )
            )
         )
      )
      (If (> (SsLength SS-LAYER) 0)
         (Progn
            (bump "Fixing layers")
            (Command
               "_.chprop" SS-LAYER "" "_LA" BLAYER ""
            )
         )
      )
      (If (> (SsLength SS-COLOR) 0)
         (Progn
            (bump "Fixing colors")
            (Command
               "_.chprop" SS-COLOR "" "_C" BCOLOR ""
            )
         )
      )
      (If (> (SsLength SS-LTYPE) 0)
         (Progn
            (bump "Fixing linetypes")
            (Command
               "_.chprop" SS-LTYPE "" "_LT" BLTYPE ""
            )
         )
      )
   )
 
   ;-----------------------------------------------------
   ; BURST MAIN ROUTINE
   ;-----------------------------------------------------
 
   (Defun BURST (/ SS1)
      (setq PSFLAG (if (= 1 (caar (vports)))
                       1 0
                   )
      )
      ;(setq ss1 (ssget "_X" ))
      (Setq SS1 (SsGet "_X" (list (cons 0 "INSERT")(cons 67 PSFLAG))))
      (If SS1
         (Progn
            (Setvar "highlight" 0)
            (terpri)
            (Repeat
               (SsLength SS1)
               (Setq ENAME (SsName SS1 0))
               (SsDel ENAME SS1)
               (BURST-ONE ENAME)
            )
            (princ "\n")
         )
      )
   )
 
   ;-----------------------------------------------------
   ; BURST COMMAND
   ;-----------------------------------------------------
 
   (BURST)
 
  (acet-error-restore)
 
);end defun


(princ)
Title: Re: Bursting a previously inserted block?
Post by: Joe Burke on October 10, 2007, 12:32:13 PM
Hacking old code which you don't fully understand is a recipe for problems down the road.

Roll your own which you fully understand.