Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Repeat (c:burst) command in lisp routine

29 REPLIES 29
Reply
Message 1 of 30
stoews1
2600 Views, 29 Replies

Repeat (c:burst) command in lisp routine

I am creating a lisp routine to clean up xrefs from architectural drawings for use in our draiwngs. As part of my routine, I want to burst the drawing several times to get rid of all of the blocks within blocks until the whole drawing is single entities. I've tried using the repeat command with (c:burst) and it works until there is "0 found" objects. At which point the lisp routine ends without carrying on. If I say for it to repeat for example 3 times, and it takes exactly 3 times to burst everything into single entities, the routine continues on. It only causes an error if it finds "0 found" before it has repeated the specified number of times. is there a way to make it do a "burst" as many times as needed until there is "0 found" and then continue on with the routine.

this is the part of the lisp routine in question:

(repeat 5
(sssetfirst nil (ssget "X" (list )))
(c:burst)
)
29 REPLIES 29
Message 21 of 30
Kent1Cooper
in reply to: mwhea


@mwhea wrote:

..... Will this fail if the selection set of blocks is greater then the maximum allowed by AutoCAD (32767) ?? ....

 


I'm afraid I may not put that many Blocks, of all kinds combined, into all the drawings I work on in a year, so I couldn't say.  If the maximum allowed means that trying to put more into a selection set will cause an error, then I would assume the answer is yes.  If it only means that the selection set won't have everything eligible in it, but will still be viable with whatever it can hold, then I would assume the answer is no, and that the routine will just take an additional round [or more] to get to everything, because some Blocks will be omitted with each round until the number falls within the allowable limit.  Others may have experience with pushing things to numerical limits like that.

Kent Cooper, AIA
Message 22 of 30
mwhea
in reply to: Kent1Cooper

Yeah the archietct we use has a strange way of drawing i guess.. haha

 

Though i could only assume that this is the cause of the lisp routine failing - just opening the file there is 9000 objects in the drawing upon running a burst all on the drawing in properties after selecting all entities there is "No Selection" so i'd guess after first burst of objects it has pushed passed the maximum limit AutoCAD allows for a selection hence then making the routine fail. I'll have to look around to see if there is a way to set a maximum amount of objects selected using SSGET.

Message 23 of 30
mwhea
in reply to: mwhea

I investigated into each section of the drawing seems there is a non exploadable Block Reference - so the routine is obviously finding 1 block and because it cannot burst its just stuck on a constant loop.

 

The block has no block reference though.. even if pasted into a new drawing it cannot be edited. 

Message 24 of 30
pbejse
in reply to: mwhea

Do you want to make this blocks exploadable? 

 

Message 25 of 30
mwhea
in reply to: pbejse

Yes that is the idea because it is forcing the Burstzero routine to be stuck in a forever loop as there is 1 block still found that cannot be bursted. 

 

I have attached the object from within the architectural that i cannot seem to find a way to burst. 

 

I run this routine before running the Burstzero routine to stop "non-exploadable" blocks from making the lisp routine freeze.

 

(defun c:eb ()
  (vlax-map-collection
	(vla-get-blocks
	  (vla-get-activedocument (vlax-get-acad-object))
	)
	'(lambda (x)
	   (and
	 (vlax-property-available-p x 'explodable)
	 (eq (vlax-get-property x 'explodable) :vlax-false)
	 (not (vlax-put-property x 'explodable :vlax-true))
	   )
	 )
  )
)

 

Message 26 of 30
pbejse
in reply to: mwhea

Hang-on i'll try to look for the recursive code i posted for exploding blocks.......

One question though. the sample you posted doesnt have attributes? do you need to explode that block as well?

 

 

 

Message 27 of 30
mwhea
in reply to: pbejse

Yeah attributes or not its just part of the cleaning routine of the archtectural files because every thing eventually gets turned to colour 8 for inserting as a underlay to our electrical drawings. And because the script for batching the drawings calls for the overall lisp routine burstzero is run and it puts a hold on the script process because it is stuck in a constant loop of trying to burst that 1 block remaining in the drawing. 

Message 28 of 30
pbejse
in reply to: mwhea

Explode all  the Nested Blocks:

 

<Exclusively Model Space> 

 

(Defun c:ExAll ( / _ExplodeBlocks aDoc lst Blkcoll bn )
;;;			 pBe 13Mar2013				;;;
(vl-load-com)
(defun _ExplodeBlocks  (bname BC)
  (if (not (member bname lst))
    (progn
      (setq lst (cons bname lst)
            obj (vla-item BC bname))
      (if (eq (vla-get-Explodable obj) :vlax-false)
        	(vla-put-Explodable obj :vlax-true))
      (vlax-for itm  obj
        (if (eq "AcDbBlockReference"
            (vla-get-objectname itm))
           (progn
                (setq bn (vla-get-name itm))
             	(vla-explode itm)
             	(vla-delete itm)
             (_ExplodeBlocks  bn BC)
             )))))
  )
	                  
(setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object)))      
(setq lst nil ss (ssadd)  Blkcoll (vla-get-blocks aDoc))
(vlax-for itm Blkcoll
	(setq a (cons itm a)))
(vlax-for itm Blkcoll
              (cond ((and
                        (eq :vlax-false (vla-get-islayout itm))
                        (eq :vlax-false (vla-get-IsXref itm))
                        (not (wcmatch (setq bn (vla-get-name itm)) "`*D*"))
    			(_ExplodeBlocks (Vla-get-name itm) Blkcoll)
                        ))))
;(vlax-for layout (vla-item (vla-get-layouts aDoc) "Model")
    (vlax-for i (vla-get-block (vla-item (vla-get-layouts aDoc) "Model"))
      (if  (and (eq (vla-get-objectname i) "AcDbBlockReference")
           (not (vlax-property-available-p i 'path)))
        (if  (eq (Vla-get-hasAttributes i) :Vlax-true)

          	(ssadd (vlax-vla-object->ename i) ss)
          	(progn (vlax-invoke i 'Explode) (vla-delete i)))
          )
      )
  ;)
  (if (> (sslength ss) 0)
    	(progn
          (sssetfirst nil ss)
          (c:burst)
          ))
      (vla-regen aDoc acActiveViewport)
      )

 

EDIT: misplaced cond.

Message 29 of 30
mwhea
in reply to: Kent1Cooper

Thanks once again pbejse

 

Just quickly i am guessing this routine is only bursting objects and not actually exploading it using the "explode" command, also just want to clarify what exactly this routine is doing 🙂 

 

Is it sifting through all blocks in the drawing in model space and then going through and bursting everything out even that non exploadable block (it worked really well on that drawing). I guess what i am asking is will it burst all blocks till there is no more found and what about xrefs that are attached to the drawing will that cause any problems??

Message 30 of 30
pbejse
in reply to: mwhea


@mwhea wrote:

Thanks once again pbejse

 

Just quickly i am guessing this routine is only bursting objects and not actually exploading it using the "explode" command, also just want to clarify what exactly this routine is doing 🙂 

 

Is it sifting through all blocks in the drawing in model space and then going through and bursting everything out even that non exploadable block (it worked really well on that drawing). I guess what i am asking is will it burst all blocks till there is no more found and what about xrefs that are attached to the drawing will that cause any problems??


Burst for attribute blocks in one go and use VL explode method for the rest. 

 

Yes, only on model space [guess you need to add (setvar 'ctab "Model") on the start of the rouitne as Kent suggested otherwise (foreach lay (cons "Model" (layoutlist))....) <the burst command limitation is the object needs to be on the current layout>

 

non-explodable blocks are dealt with prior to object selection via block collection. [exploadable flag and explode]. whcih means there is no need to repeat burst as it ensures all nested blocks are already exploded. [unless the nested ones include attributes as well then we may need to write our own version of "Burst"

 

Xrefs are excluded, unless you want to bind them first and be treated as regular blocks.

 

 

HTH

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost