"NUKE" lisp?

"NUKE" lisp?

Netelaana
Enthusiast Enthusiast
4,260 Views
25 Replies
Message 1 of 26

"NUKE" lisp?

Netelaana
Enthusiast
Enthusiast

I have a CAD file with a couple layouts. I need to reduce the model & layouts content to its constituent parts without loosing visible information. Manually I go about it in this way:

 

1. select all

     -burst

          -repeat until no more items to burst

2. select all 

     - explode (ideally blocks explode onto the blocks layer not "0")

3. repeat 1&2 until no more items to burst or explode. 

4. repeat 1-3 for each layout

5. purge all

6. audit - fix errors

 

This seems an ideal job for a LISP that might aptly be named "NUKE"

Something along the lines of lee mac http://www.lee-mac.com/upgradedburst.html makes me think it should be possible. 

 

As one can imagine, this process takes quite a bit of time. Any help would be greatly appreciated,

 

Thanks!

0 Likes
4,261 Views
25 Replies
Replies (25)
Message 21 of 26

roland.r71
Collaborator
Collaborator

Ok.

 

Don't forget it requires Lee Mac's "Burst upgraded v1.7". Which you can find >here< along with a ton of other goodies 🙂

0 Likes
Message 22 of 26

roland.r71
Collaborator
Collaborator

I just tested it myself on a set of layouts containing circuit diagrams and it worked like a charm.

 

I just added some comments, an extra warning at the start and a "undo".

 

(defun c:NukeDWG ( / ltab bss fnd)

   ; Function to "nuke" a set of layouts down to nothing but poly's & text
   
   ; Note: This function requires Lee Mac's Burst Upgraded v1.7
   ;       as found at: http://lee-mac.com/upgradedburst.html   

   ; USE WITH CAUTION !
   
   (setq cmdecho (getvar "cmdecho"))
   (setvar "cmdecho" 0)
   (command "_.UNDO" "_Begin")
   
   ; The process of bursting everything on each layout can take quite some time.
   ; ACAD might report as "not responding", while it is working in the background.
   
   (alert "WARNING: This dwg is about to get Nuked!\n\nnote: this process can take a while.")
   (foreach ltab (layoutlist)
      (setvar 'ctab ltab)
      (command "_zoom" "_a")                           
      (setq bss (ssget "X" (list (cons 0 "INSERT")(cons 410 ltab)))
      )
      (princ"\n---------------------------------------")
      (if bss
         (progn
            (princ (strcat "\nBursting blocks on layout: " ltab))
            (LM:burstsel bss t)
            (setq fnd t)
            (command "_explode" "all")                       
         )
         (princ (strcat "\nNo blocks found on layout: " ltab))
      )
   )
   (princ"\n---------------------------------------")
   (command "_purge" "all" "*" "N")
   (command "_OVERKILL" allobjects "" "Yes" "Yes")
   (command "_AUDIT")
   (if fnd
      (alert "This drawing got Nuked!")
      (alert "No blocks present in drawing!")
   )
   (command "_.UNDO" "_End")
   (setvar "cmdecho" cmdecho) 	
   (princ)
)
0 Likes
Message 23 of 26

Netelaana
Enthusiast
Enthusiast

thanks! finally got a chance to try it. It sort of does the trick - polylines, mtext and a few attributes are left un-exploded in paperspace (due to nesting?), and model space does not seem to participate - all blocks are still intact.

0 Likes
Message 24 of 26

roland.r71
Collaborator
Collaborator

I didn't go as far as exploding each polylines, I think I know why the mtext didn't get exploded, wasn't sure if it was supposed too. & it currently only works on layouts, so yes, modelspace was left untouched. Which all can be arranged.

 

...but remaining attributes ? that's a wierd one.

 

edit:

Could you possibly share a sample drawing to test with?

0 Likes
Message 25 of 26

ronjonp
Advisor
Advisor

What is the purpose of this simplification? Does it get fed to a machine that cannot handle complex objects?

 

You might want to wrap your code in something like this so that all layers are unlocked and all blocks are made 'explodable'.

(defun c:foo (/ a d)
  (setq d (vla-get-activedocument (vlax-get-acad-object)))
  ;; Unlock all layers
  (vlax-for l (vla-get-layers d)
    (cond ((= -1 (vlax-get l 'lock)) (vlax-put l 'lock 0) (setq a (cons l a))))
  )
  ;; Make all blocks explodable
  (vlax-for b (vla-get-blocks d)
    (and (= 0 (vlax-get b 'isxref) (vlax-get b 'islayout)) (vlax-put b 'explodable -1))
  )
  ;; Your bustemupcode :)

  
  ;; Relock layers
  (foreach l a (vl-catch-all-apply 'vlax-put (list l 'lock -1)))
  (princ)
)
(vl-load-com)
0 Likes
Message 26 of 26

Netelaana
Enthusiast
Enthusiast

There are a couple of different factors that converge and create this need, almost all of them outside of my control - some for input into other program, some policy, some historical precedent from when everything was just basic line/stick drawings. If it would be possible to add a round or two of explode & burst on each layout and the model, that would be ideal.

 

Again, my current manual workflow looks like:

1. in model space, select all, burst, repeat until no more items to burst

2. select all, explode once (ideally blocks explode onto the blocks layer not "0")

3. repeat steps 1-2 until no more items to burst or explode.

4. repeat steps 1-3 (in paperspace) for each layout

5. purge all; overkill; audit

6. audit - fix errors

 

any help automating that workflow would be fantastic.

0 Likes