Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
ossmo02
Posts: 55
Registered: ‎10-09-2006
Message 1 of 8 (779 Views)
Accepted Solution

burst & purge blocks in a lisp

779 Views, 7 Replies
11-15-2011 03:48 PM

 

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.

 

*Expert Elite*
pbejse
Posts: 2,459
Registered: ‎11-24-2009
Message 2 of 8 (773 Views)

Re: burst & purge blocks in a lisp

11-15-2011 09:15 PM in reply to: ossmo02

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

 

*Expert Elite*
pbejse
Posts: 2,459
Registered: ‎11-24-2009
Message 3 of 8 (767 Views)

Re: burst & purge blocks in a lisp

11-15-2011 09:43 PM 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

 

 

Valued Contributor
ossmo02
Posts: 55
Registered: ‎10-09-2006
Message 4 of 8 (750 Views)

Re: burst & purge blocks in a lisp

11-16-2011 07:13 AM 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.

Valued Contributor
ossmo02
Posts: 55
Registered: ‎10-09-2006
Message 5 of 8 (747 Views)

Re: burst & purge blocks in a lisp

11-16-2011 07:32 AM 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)
)

 

Valued Contributor
ossmo02
Posts: 55
Registered: ‎10-09-2006
Message 6 of 8 (746 Views)

Re: burst & purge blocks in a lisp

11-16-2011 07:34 AM in reply to: ossmo02

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

*Expert Elite*
pbejse
Posts: 2,459
Registered: ‎11-24-2009
Message 7 of 8 (724 Views)

Re: burst & purge blocks in a lisp

11-16-2011 08:47 PM in reply to: ossmo02

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")
   )
  )

 


ossmo02 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)
)       

 


       

Valued Contributor
ossmo02
Posts: 55
Registered: ‎10-09-2006
Message 8 of 8 (695 Views)

Re: burst & purge blocks in a lisp

11-18-2011 05:55 AM 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.

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.