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

burst & purge blocks in a lisp

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Anonymous
1814 Views, 7 Replies

burst & purge blocks in a lisp

 

My goal is to activate the lisp & have the block "BOM" burst so that it retains the information but can be purged, then have the blocks "BOM" & "LINDSAY" (nested in "BOM") purged.  For the burst portion it makes no difference to me if it selects the "BOM" block in the program or if I have to highlight it.  It should be noted that I am a beginner when it comes to lisp, I have some very basic things down which makes me think this can be done, but also could make me dangerous with it too.

 

This is code that I have written and it has me puzzled, it mimics other code in my Acaddoc.lsp file which is where I have located this as well;

 

;;;----------------------------------------------------------------------------
;;;BURST SHORTCUT
;;;----------------------------------------------------------------------------
(defun c:BU ()
(C:BURST)
)
(PRINC)
)

;;;----------------------------------------------------------------------------
;;;"BOM" PURGE
;;;----------------------------------------------------------------------------
(DEFUN C:BP ()
(COMMAND "-PURGE" "BLOCKS" "BOM" "no")
(princ)
)

;;;----------------------------------------------------------------------------
;;;"LINDSAY" PURGE
;;;----------------------------------------------------------------------------
(DEFUN C:LP ()
(COMMAND "-PURGE" "BLOCKS" "LINDSAY" "NO")
(princ)
)

;;;----------------------------------------------------------------------------
;;;BURST & PURGE
;;;----------------------------------------------------------------------------
(DEFUN C:BX ()
(C:BU)
(C:BP)
(C:LP)
(PRINC)
)

 

The burst shortcut works with no problem, however the "BOMPURGE" & "LINDSAYPURGE" are unknown commands per the command line.  I have tried "purge", "_purge" also used the letters B for block & N for no instead of the words, tried the block name with & without the quotes all of which return the same result.  From what I have seen in my search of this database my code should work as it appears to match what other have written, which makes me think its something very simple & I am overlooking it.

 

I also tried;

 

(DEFUN C:BP ()
(setq blockname "BOM")
(setq ss nil)
(setq ss (ssget "X" (list (cons 2 BOM))))
(if ss
(progn
(command "_BURST" ss "")
(command "_purge" "B" BOM "Y" "")
); progn
); if

 

which is code that I found on this board by EC-CAD for erasing a block & purging it, replaced the erase command with the burst to no avail.  Any help on this would be greatly appreciated.

 

7 REPLIES 7
Message 2 of 8
pbejse
in reply to: Anonymous

is the "LINDSAY" block contains attributes? do you want that block burst as well?

 

Message 3 of 8
pbejse
in reply to: pbejse

 

If it (LINDSAY) has attributes use this:

 

(Defun c:BBL (/ ss mn mn)
(vl-load-com)  
  	(if (setq ss (ssget "_X" (list '(0 . "INSERT")'(66 . 1)'(2 . "BOM")(cons 410 (getvar 'CTAB)))))
  		(progn
			(vla-getboundingbox
			  (vlax-ename->vla-object (setq e (ssname ss 0)))
			  'mn
			  'mx
			)
			(sssetfirst nil (ssadd e))
  			(c:burst)
	  		(if (sssetfirst
			      nil
			      (ssget "_W"
				     (vlax-safearray->list mn)
				     (vlax-safearray->list mx)
				     '((0 . "INSERT")
				       (66 . 1)
				       (2 . "LINDSAY")
				      )
			      )
			    )
	  			(c:burst))
		  	(command "_purge" "BLocks" "BOM,LINDSAY" "_N")
		))
  (princ)
  )

 If not

 

(Defun c:BBL (/ ss mn mn)
(vl-load-com)  
  	(if (setq ss (ssget "_X" (list '(0 . "INSERT")'(66 . 1)'(2 . "BOM")(cons 410 (getvar 'CTAB)))))
  		(progn
			(vla-getboundingbox
			  (vlax-ename->vla-object (setq e (ssname ss 0)))
			  'mn
			  'mx
			)
			(sssetfirst nil (ssadd e))
  			(c:burst)
	  		(if (setq ss 
			      (ssget "_W"
				     (vlax-safearray->list mn)
				     (vlax-safearray->list mx)
				     '((0 . "INSERT")
				       (66 . 1)
				       (2 . "LINDSAY")
				      )
			      )
			    )
	  			(command "_explode" ss))
		  	(command "_purge" "BLocks" "BOM,LINDSAY" "_N")
		))
  (princ)
  )

 

 

Hope this helps

 

 

Message 4 of 8
Anonymous
in reply to: pbejse

Thank you for the quick response.  Yes the block named "Lindsay" does contain attributes. I tried both codes & neither seemed to do anything.

Message 5 of 8
Anonymous
in reply to: pbejse

;;;----------------------------------------------------------------------------
;;;BURST HOTKEY
;;;----------------------------------------------------------------------------
(defun c:BU () 
(C:BURST)
)
(PRINC)
)

;;;----------------------------------------------------------------------------
;;;"BOM" PURGE
;;;----------------------------------------------------------------------------
(DEFUN C:BOMPURGE ()
(COMMAND "_purge" "BLocks" "BOM" "_N")
(princ)
)

;;;----------------------------------------------------------------------------
;;;"LINDSAY" PURGE
;;;----------------------------------------------------------------------------
(DEFUN C:LINDSAYPURGE ()
(COMMAND "_purge" "BLocks" "LINDSAY" "_N")
(princ)
)

;;;----------------------------------------------------------------------------
;;;BURST PURGE
;;;----------------------------------------------------------------------------
(DEFUN C:BX ()
(C:BU)
(C:BOMPURGE)
(C:LINDSAYPURGE)
(PRINC)
)

 

Message 6 of 8
Anonymous
in reply to: Anonymous

This is my code now, after re apploading I get BU, BOMPURGE & LINDSAYPURGE, to work seperatly & in the order, but my system still does not recognize the BX command

Message 7 of 8
pbejse
in reply to: Anonymous

Reasons the code might not work or "neither seemed to do anything"

* (setq ss (ssget "_X" (list '(0 . "INSERT")'(66 . 1)
 '(2 . "BOM")<-----Block "BOM" Not found, could be "anonymously named block" <"*U4">, in this case we may need to use '(2 . "`*U*,BOM") and
 check each block effectivename

* Block explodable property is 0        

* pickfirst is 0
 (sssetfirst nil (ssadd e))<---  wont work at all

* (ssget "_W" <----- selection area must be visible on screen so (command "_zoom" "Object"...) would be invoke
  (vlax-safearray->list mn)
  (vlax-safearray->list mx)
  '((0 . "INSERT")
    (66 . 1)
    (2 . "LINDSAY")
   )
  )

 


@Anonymous wrote:

This is my code now, after re apploading I get BU, BOMPURGE & LINDSAYPURGE, to work seperatly & in the order, but my system still does not recognize the BX command


As for your code

 

(defun c:BU ()
(C:BURST)
(COMMAND "_purge" "BLocks" "BOM" "_N")
(COMMAND "_purge" "BLocks" "LINDSAY" "_N") 
(PRINC)
)       

 


       

Message 8 of 8
Anonymous
in reply to: pbejse

I am not sure why but when I type the code to match the corrections you made to mine it does not work, but if i copy & paste & changed the BU to BZ it works.  Thank you for your assistance.

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report