See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Using the Burst command with LISP ?

  1. #1
    I could stop if I wanted to
    Join Date
    2005-08
    Posts
    378
    Login to Give a bone
    0

    Cool Using the Burst command with LISP ?

    Guys,
    I have a routine that I wish to use the Burst command with. I can give it a selection set etc though have no idea how to call the command with lisp. I think it is an express tools command ?
    I want to explode all attributes on the drawing, is there another way ?


    Stephen

  2. #2
    Active Member
    Join Date
    2007-03
    Posts
    57
    Login to Give a bone
    0

    Default Re: Using the Burst command with LISP ?

    this is some my functions
    Code:
    ;;; Need Express Tools !!!
    ;;;********* Some function from BURST.LSP ************
    (Defun ITEM (N E) (CDR (Assoc N E)))
    (acet-error-init (list (list "cmdecho" 0
    "highlight" 1) T))
    (Defun BITSET (A B) (= (Boole 1 A B) B))
    (Defun bump (prmpt)(terpri)(Princ prmpt))
    (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)))
    (Defun LASTENT (/ E0 EN)(Setq E0 (EntLast))
    (While (Setq EN (EntNext E0))(Setq E0 EN)) E0)
    (Defun BURST-ONE (BNAME / BENT ANAME ENT ATYPE AENT AGAIN ENAME
             ENT SS-COLOR SS-LAYER SS-LTYPE mirror ss-mirror mlast)
     (Setq BENT   (EntGet BNAME) BLAYER (ITEM 8 BENT) BCOLOR (ITEM 62 BENT)
         BCOLOR (Cond ((> BCOLOR 0) BCOLOR)((= BCOLOR 0) "BYBLOCK")("BYLAYER"))
             BLTYPE (Cond ((ITEM 6 BENT)) ("BYLAYER")))
     (Setq ELAST (LASTENT))
    (If (= 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))
     (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 ""))))
     ;;;*************** END Burst.lsp *******************************
    
    ;;Original posted http://dwg.ru/forum/printtopic.php?t=9705
    ;;;Function make:
    ;;; BLOCK - burst
    ;;; Dimention, region - EXPLODE
    ;;; Burst all nested blocks
    ;;; 
    ;;; 
    ;;; blk - Ename block's
    ;;; Return Selection Set with entities (set in global variable *ssRET*)
    ;;; 
    
    (defun exp_blk ( blk  / adoc csp blk_obj)
    ;_BURST block and return list of object
    (defun BURST-LIST (blk / ret sc ec)
      (setq sc (1-(vla-get-count csp)))
      (BURST-ONE blk)
      (setq ec (vla-get-count csp))
      (while (< sc ec)
        (setq memb (vla-item csp sc))
        (setq ret (append ret (list memb)))
        (setq sc(1+ sc))) ret)
    ;_Expolde object and ssadd result to *ssREt*
    (defun EXP2SS (en / sc ec)
      (setq sc (1-(vla-get-count csp)))
      (vl-cmdf "_.EXPLODE" en)
      (setq ec (vla-get-count csp))
      (while (< sc ec)
        (setq memb (vla-item csp sc))
        (ssadd (vlax-vla-object->ename memb) *ssRET*)
        (setq sc(1+ sc))))
    ;_Cycle on block primitive things
    ;_It is necessary to explode nested blocks
    ;_SSadd result to *ssREt*
    ;_ blk - Ename block
      
    (defun exp-blk-ss (blk / memb name)
    (foreach memb (BURST-LIST Blk)
      (setq name (vla-get-ObjectName memb))
      (cond ((= name "AcDbBlockReference")(exp-blk-ss (vlax-vla-object->ename memb)));_BURST block
    	((wcmatch (strcase name) "*DIMENSION,*REGION");_Explode dimention and region
    	 (exp2SS (vlax-vla-object->ename memb)))
    	(t  (ssadd (vlax-vla-object->ename memb) *ssRET*)))))
      (setq adoc (vla-get-activedocument (vlax-get-acad-object))
    	blk_obj (vlax-ename->vla-object blk)
    	csp (vla-ObjectIDToObject adoc (vla-get-OwnerID blk_obj)))
      (if (/= (type *ssRet*) 'PICKSET)(setq *ssRET* (ssadd)))
      (exp-blk-ss blk)
    *ssRET*)
    And Example: burst selected block and set all entities color to red
    Code:
    ;;Example  - burst block and set all entities color to red
    (defun C:TEST ( / blk ss)
    (if (and
          (princ "\nSelect block:")
          (setq ss (ssget "_:S:E:L" '((0 . "INSERT"))))
          (setq blk (ssname ss 0))
          )
      (progn
        (setq *ssRET* nil *ssRET*  (ssadd))
        (exp_blk blk)
        (command "_CHANGE" *ssRET* "" "_P" "_C" 1 "")
        )
      )
      (setq *ssRET* nil)
      (princ)
      )

  3. #3
    Active Member
    Join Date
    2007-03
    Posts
    57
    Login to Give a bone
    0

    Default Re: Using the Burst command with LISP ?

    Try it. Other function above
    Code:
    ;;Burst All Attribute
    (defun C:BAA ( / ss Doc *error*)
    (defun *error* (msg)(princ msg)(vla-EndUndoMark Doc))
    (vl-load-com)
    (setq Doc (vla-get-ActiveDocument(vlax-get-Acad-object))) 
    (vla-StartUndoMark Doc) 
    (if (setq ss (ssget "_X"                         ;_Select
    		      (list
    			(cons 0  "INSERT")             ;_All block
    			(cons 66  1)                   ;_With attribute
    			(cons 410 (getvar "CTAB")) ;_In current space
    			)
    		      )
    	    ) 
      (progn
       (vlax-for lay (vla-get-Layers Doc)
         (if (eq (vla-get-Lock lay) :vlax-true)
           (vla-put-Lock Lay :vlax-false))  ;_Unlock layer
         (if (eq (vla-get-freeze lay) :vlax-true)
           (vla-put-Freeze Lay :vlax-false)) ;_thaw layer
         )
        (setq *ssRET* nil *ssRET*  (ssadd))
        (foreach blk (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
          (exp_blk blk)
          )
       ;;;Set to previous selection
        (command "_Select" *ssRET* "")
        )
      )
      (vla-EndUndoMark Doc) 
      (setq *ssRET* nil)
      (princ)
      )

  4. #4
    I could stop if I wanted to
    Join Date
    2005-08
    Posts
    378
    Login to Give a bone
    0

    Cool Re: Using the Burst command with LISP ?

    azarko,
    Thank for these. I haven't the chance yet to play with them though grately appreciate your assistance.

    Stephen

  5. #5
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    3,401
    Login to Give a bone
    1

    Default Re: Using the Burst command with LISP ?

    Quote Originally Posted by stephen.coff
    Guys,
    I have a routine that I wish to use the Burst command with. I can give it a selection set etc though have no idea how to call the command with lisp. I think it is an express tools command ?
    I want to explode all attributes on the drawing, is there another way ?


    Stephen
    (sssetfirst nil ss) makes ss both gripped and selected.
    Then just use (c:burst) to call the Burst command.
    Tom Beauford P.S.M. - Civil 2020 on Windows 10 Enterprise
    Design Analysis - Leon County Public Works/Engineering Wrap [CODE] tags around selected text
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516 Home Page

  6. #6
    I could stop if I wanted to
    Join Date
    2005-08
    Posts
    378
    Login to Give a bone
    0

    Cool Re: Using the Burst command with LISP ?

    Tom,
    Thanks for your reply. I am sorry I am not understanding how to utilise what you have told me. I tried the following though it's not correct, could you please expalin a little further?

    (setq ss1 (ssget "x")) ; selects everything and assigns to ss1.
    (sssetfirst nil ss1) ; grabs everything both gripped and selected.
    (c:burst) ; runs the burst command but command line entry only?

    I am not sure how to utilise the (c:burst) with the above selection set through lisp.

    Stephen

  7. #7
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    3,401
    Login to Give a bone
    0

    Default Re: Using the Burst command with LISP ?

    Quote Originally Posted by stephen.coff
    Tom,
    Thanks for your reply. I am sorry I am not understanding how to utilise what you have told me. I tried the following though it's not correct, could you please expalin a little further?

    (setq ss1 (ssget "x")) ; selects everything and assigns to ss1.
    (sssetfirst nil ss1) ; grabs everything both gripped and selected.
    (c:burst) ; runs the burst command but command line entry only?

    I am not sure how to utilise the (c:burst) with the above selection set through lisp.

    Stephen
    See if this works.
    Code:
     ;Explodes All
    (defun C:XE ( / ssAll drwordr)
      (setq ssAll (ssget "X" '((0 . "INSERT")))
    	   drwordr (getvar "draworderctl")
      )
      (setvar "draworderctl" 0);supress warnings
      (sssetfirst nil ssAll) ;makes ssAll both gripped and selected. 
      (c:burst)
      (setvar "draworderctl" drwordr)
    );end defun
    It is slowed by gripping and working thru the selection as it does. The best might be to save the "Burst.lsp" to something like "BurstRed.lsp" and add a small function at the end to Burst and modify your selection.
    Tom Beauford P.S.M. - Civil 2020 on Windows 10 Enterprise
    Design Analysis - Leon County Public Works/Engineering Wrap [CODE] tags around selected text
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516 Home Page

  8. #8
    I could stop if I wanted to
    Join Date
    2005-08
    Posts
    378
    Login to Give a bone
    0

    Cool Re: Using the Burst command with LISP ?

    Tom,
    Sorry for the late reply. Thank you very much, that helps heaps.

    Stephen

  9. #9
    I could stop if I wanted to USMCBody's Avatar
    Join Date
    2008-05
    Location
    Yardley, PA
    Posts
    304
    Login to Give a bone
    0

    Default Re: Using the Burst command with LISP ?

    I also am haveing problems.. and I'm also a green at programming so please bear with me...

    So, I like Tom's approach becasue I can understand it easier, but one thing is that I have problems with is that I set a lot of blocks to not explode... How do I get into the properties of each block and turn on exploding first and then burst all of the blocks?

  10. #10
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL
    Posts
    3,401
    Login to Give a bone
    0

    Default Re: Using the Burst command with LISP ?

    In the help look for AutoLISP Reference Guide > AutoLISP Functions > S Functions > ssget. The (ssget "X" '((0 . "INSERT"))) selects every block insert in the drawing. Modify that line to suit your selection needs. You could simply remove the "X" and pick the blocks you want to explode.
    Tom Beauford P.S.M. - Civil 2020 on Windows 10 Enterprise
    Design Analysis - Leon County Public Works/Engineering Wrap [CODE] tags around selected text
    2280 Miccosukee Rd. Tallahassee, FL 32308-5310
    Ph# (850)606-1516 Home Page

Page 1 of 2 12 LastLast

Similar Threads

  1. 2014: BURST command Error
    By darrellwinfrey589074 in forum AutoCAD General
    Replies: 2
    Last Post: 2014-03-25, 02:56 PM
  2. Convert Explode command to Burst command?
    By stusic in forum AutoLISP
    Replies: 39
    Last Post: 2013-06-18, 11:55 PM
  3. Looking to get the BURST command in LT
    By elipman in forum AutoCAD LT - General
    Replies: 3
    Last Post: 2011-11-14, 01:19 PM
  4. Modified Burst Command
    By thomas-p in forum AutoLISP
    Replies: 6
    Last Post: 2006-03-17, 02:51 PM
  5. BURST command in Lisp Routine
    By mhollar in forum AutoLISP
    Replies: 6
    Last Post: 2005-12-19, 11:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •