Jump to content

lisp to find convert all unexplodable blocks within a file to explodable blocks


Recommended Posts

Posted

Hi. Is there any lisp to  to find convert all unexplodable blocks within a file to explodable blocks? You can set a block as  explodable or unexplodable while creating a block or change this property later, but block by block. What I want is a lisp to convert all unexplodable blocks to explodable blocks.

 

Thanks in advance.

Posted

Here's a quick one:

(defun c:foo nil
  ;; RJP » 2021-08-05
  (vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
    (if	(= 0 (vlax-get b 'islayout) (vlax-get b 'isxref))
      (vlax-put b 'explodable -1)
    )
  )
  (princ)
)

 

  • Like 2
Posted
On 8/5/2021 at 3:22 PM, ronjonp said:

Here's a quick one:


(defun c:foo nil
  ;; RJP » 2021-08-05
  (vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
    (if	(= 0 (vlax-get b 'islayout) (vlax-get b 'isxref))
      (vlax-put b 'explodable -1)
    )
  )
  (princ)
)

 

I like your other way (from my link) better

Posted
11 minutes ago, Steven P said:

I like your other way (from my link) better

Why? This one does all block definitions.

Posted (edited)
On 8/5/2021 at 7:12 AM, Steven P said:

Google is your friend, I like google.... 1st result:

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-make-unexplodable-blocks-explodable/td-p/2107647 

2nd page and a LISP by RonJon (just stealing his thunder, no doubt he will be along later with the same link)

ronjonp posted 3 different codes you should have linked to the one you liked and why to be clearer.

Normally I'd always go with a coders recent post which he posted here yesterday but I did like the added option in his third post. It was on the second page.

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-make-unexplodable-blocks-explodable/m-p/9314254#M395882

I use a lot of ronjonp's code on a daily basis like https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/publish-to-pdf-default-location/m-p/9831049#M406719

and snippets like

  (defun Trim0s (xb) ; Thank ronjonp
	(if (= (type xb) 'real); Trim 0's from end of string conversion, then trim . if it's at the end afterwards.
	  (vl-string-right-trim "." (vl-string-right-trim "0" (vl-princ-to-string xb)))
	  (itoa xb); if integer convert to string without trimming 0's from end.
	)
  )

in code like: http://forums.augi.com/showthread.php?171064-Linetypes-and-Text-readability&p=1333199&viewfull=1#post1333199

that keeps my workflow running smooth. Thanks ronjonp!

Edited by tombu
Posted (edited)
46 minutes ago, tombu said:

ronjonp posted 3 different codes you should have linked to the one you liked and why to be clearer.

Normally I'd always go with a coders recent post which he posted here yesterday but I did like the added option in his third post. It was on the second page.

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-make-unexplodable-blocks-explodable/m-p/9314254#M395882

I use a lot of ronjonp's code on a daily basis like https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/publish-to-pdf-default-location/m-p/9831049#M406719

and snippets like



  (defun Trim0s (xb) ; Thank ronjonp
	(if (= (type xb) 'real); Trim 0's from end of string conversion, then trim . if it's at the end afterwards.
	  (vl-string-right-trim "." (vl-string-right-trim "0" (vl-princ-to-string xb)))
	  (itoa xb); if integer convert to string without trimming 0's from end.
	)
  )

in code like: http://forums.augi.com/showthread.php?171064-Linetypes-and-Text-readability&p=1333199&viewfull=1#post1333199

that keeps my workflow running smooth. Thanks ronjonp!

I do like that that snippet better :)

 

Glad you can make use of the code I provide! 🍻 That current path code with the reactor saves me sooooo much time browsing around our network.

Edited by ronjonp
  • Thanks 1
Posted (edited)

Yup, same one I was meaning, the one on the second page, 3rd post

 

 

 

("2nd page and a LISP by RonJon "... only saying.....)

Edited by Steven P
  • 4 years later...
Posted
On 8/6/2021 at 12:22 AM, ronjonp said:

Here's a quick one:

(defun c:foo nil
  ;; RJP » 2021-08-05
  (vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
    (if	(= 0 (vlax-get b 'islayout) (vlax-get b 'isxref))
      (vlax-put b 'explodable -1)
    )
  )
  (princ)
)

 

This is very useful. Is there a version of this where I can only select some blocks and not all of them?

Posted

@nolex Give this quick modification a try:

(defun c:foo (/ n nms s)
  ;; RJP » 2026-01-27
  (cond	((setq s (ssget '((0 . "INSERT"))))
	 (foreach b (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	   (or (vl-position (setq n (vla-get-effectivename (vlax-ename->vla-object b))) nms)
	       (setq nms (cons n nms))
	   )
	 )
	 (vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
	   (and	(vl-position (vla-get-name b) nms)
		(= 0 (vlax-get b 'islayout) (vlax-get b 'isxref))
		(vlax-put b 'explodable -1)
	   )
	 )
	)
  )
  (princ)
)

 

  • Like 3
Posted (edited)
On 1/28/2026 at 2:52 AM, ronjonp said:
(defun c:foo (/ n nms s)
 ;; RJP » 2026-01-27
 (cond ((setq s (ssget '((0 . "INSERT"))))
 (foreach b (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
 (or (vl-position (setq n (vla-get-effectivename (vlax-ename->vla-object b))) nms)
 (setq nms (cons n nms))
 )
 )
 (vlax-for b (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
 (and (vl-position (vla-get-name b) nms)
 (= 0 (vlax-get b 'islayout) (vlax-get b 'isxref))
 (vlax-put b 'explodable -1)
 )
 )
 )
 )
 (princ)
)

@ronjonp It's a great code!

The program performs permission to explode for all blocks of the same name.
Is it possible to perform permission to explode only for one (2, 3...) the selected block?
Is it possible to leave the other blocks of the same name unchanged?

Allow permission to explode for one of the block occurrences.

Edited by Nikon
Posted
10 hours ago, Nikon said:

@ronjonp It's a great code!

The program performs permission to explode for all blocks of the same name.
Is it possible to perform permission to explode only for one (2, 3...) the selected block?
Is it possible to leave the other blocks of the same name unchanged?

Allow permission to explode for one of the block occurrences.

Hi Nikon. I'm not sure what you're asking?

Posted

Ron, I think he thinks to make explodable only selected references and not definitions...

Unfortunately, I think this is impossible...

Posted (edited)
30 minutes ago, ronjonp said:

Hi Nikon. I'm not sure what you're asking?

I apologize for my English. I use a translator, but I'm not sure if it translates well enough.

I have several blocks with the same name. I want to allow exploding for only one selected block.

Convert one unexplodable block to explodable block (another translation).
Is it possible to leave the other blocks of the same name unchanged?

Edited by Nikon

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...