LISP explode doesn't work

Discussion in 'AutoCAD' started by CLS, Jul 21, 2004.

  1. CLS

    Doug Broad Guest

    What exactly do you want to explode? I
    can't see a reason to explode mtext or polylines,
    can you?

    Before using the command you should make sure
    all layers are unlocked as Doug Barr explained.

    If you want to include everything, you need to
    delete the (list (cons 0 . "insert")) but then
    it will error out because it tries to explode
    unexplodable objects. To include mtext and
    polyline, modify:

    (list (cons 0 . "insert,mtext,LWPOLYLINE"))

    If you explode polylines, you lose the width and
    curve fit parameters.
     
    Doug Broad, Jul 21, 2004
    #21
  2. CLS

    Doug Broad Guest

    <snicker>
     
    Doug Broad, Jul 21, 2004
    #22
  3. CLS

    CLS Guest

    Thanks Tom,

    May your next blue screen be permanent.

    Chad
     
    CLS, Jul 21, 2004
    #23
  4. CLS

    ECCAD Guest

    Long trail, but a happy camper.

    Bob
     
    ECCAD, Jul 21, 2004
    #24
  5. CLS

    Joe Burke Guest

    Hi Doug,

    Check me. I think there's a problem with xpall when the drawing contains xrefs. It
    goes into an endless loop because the xrefs can't be exploded. But of course they
    continue to be added to ss within the while loop based on the "insert" filter.
    Here's something which I think avoids that problem. It probably could be tighter, and
    it might not be perfect, but you get the idea. Comments welcome.

    (defun c:ExplodeAllInserts ( / doc mspace )
    (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
    (setq mspace (vla-get-ModelSpace doc))
    ;return T while there are inserts which are not xrefs
    (while
    (vlax-for x mspace
    (if
    (and
    (= "AcDbBlockReference" (vlax-get x 'ObjectName))
    (not (vlax-property-available-p x 'Path))
    )
    T
    )
    )
    (vlax-for x mspace
    (if
    (and
    (= "AcDbBlockReference" (vlax-get x 'ObjectName))
    (not (vlax-property-available-p x 'Path))
    )
    (progn
    (vlax-invoke x 'Explode)
    (vlax-invoke x 'Delete)
    )
    )
    )
    ) ;while
    (princ)
    ) ;end

    Regards
    Joe Burke
     
    Joe Burke, Jul 25, 2004
    #25
  6. CLS

    Doug Broad Guest

    Great points Joe. I overlooked xrefs. Oops.
    Looked at your program and made a few changes. What
    do you think?

    ;;A program by Joe Burke with changes by D.C. Broad
    ;;Explode all inserts - skip xrefs.
    (defun c:xpAll (/ doc mspace blockflag)
    (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
    (setq mspace (vla-get-ModelSpace doc))
    (setq blockflag t)
    ;;loop until no blocks are found.
    (while blockflag
    (setq blockflag nil)
    (vlax-for x mspace
    (cond
    ((and
    (= "AcDbBlockReference" (vlax-get x 'ObjectName))
    (not (vlax-property-available-p x 'Path))
    )
    ;;if a block is found assume it might have a nested
    ;;block and loop again.
    (setq blockflag t)
    (vla-explode x)
    (vla-delete x)
    ))))
    (princ))


    <snip>
     
    Doug Broad, Jul 25, 2004
    #26
  7. CLS

    Joe Burke Guest

    Doug,

    That's mo' better. :)

    I modified a bit to operate in the active space. I think that's what I would want it
    to do. But maybe it should explode all in model and paper space. What do you think?

    Joe Burke

    ;;A program by Joe Burke with changes by D.C. Broad
    ;;Explode all inserts in the current space - skip xrefs.
    (defun c:xpAll (/ doc space blockflag)
    (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
    (if (= 1 (vlax-get doc 'ActiveSpace))
    (setq space (vla-get-ModelSpace doc))
    (setq space (vla-get-PaperSpace doc))
    )
    (setq blockflag t)
    ;;loop until no blocks are found.
    (while blockflag
    (setq blockflag nil)
    (vlax-for x space
    (cond
    ((and
    (= "AcDbBlockReference" (vlax-get x 'ObjectName))
    (not (vlax-property-available-p x 'Path))
    )
    ;;if a block is found assume it might have a nested
    ;;block and loop again.
    (setq blockflag t)
    (vla-explode x)
    (vla-delete x)
    ))))
    (princ)
    ) ;end
     
    Joe Burke, Jul 26, 2004
    #27
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.