Jump to content

Recommended Posts

Posted

I need a little help redefining the explode command. I am tired of users exploding dimensions, multileaders, Civil 3D objects and so on. I want to redefine explode so that the only objects that can be exploded are blocks and polylines. I managed to get it working, but it only selects one object. When I select more than one object it only explodes the last object selected.

How do I make the lisp explode multiple polylines or blocks?

 

(command "UNDEFINE" "EXPLODE")
;undefine the Explode command

(setq echo (getvar "cmdecho"))
(setvar "cmdecho" 0)

(defun C:EXPLODE (/ blpl echo)

(alert "\nYou are ONLY allowed to explode blocks or polylines\n\nContact CAD Manager if you have questions")
;inform the user

(prompt "\nSelect a Block or Polyline: ")      

(setq blpl (ssget '((-4 . "<OR")(0 . "INSERT")(0 . "LWPOLYLINE")(-4 . "OR>"))))
(command ".EXPLODE" blpl)
;explode the object

(princ)
;finish clean

);defun

(setvar "cmdecho" echo)
;restore cmdecho

 

Posted (edited)

I think you need to set the sysvar "QAFLAGS" to 1 to allow explode to work on a selection set.

 

(setvar "QAFLAGS" 1)
(command ".EXPLODE" blpl "")
(setvar "QAFLAGS" 0)

NOTE : You have to insert a "" at the end of the command for it to work properly.

You also need to set it back immediately you've finished as, IIRC, it is an undocumented variable and could have unforseen consequences with other commands.

Edited by dlanorh
Updated code
Posted
6 hours ago, dalekr said:

I need a little help redefining the explode command. I am tired of users exploding dimensions, multileaders, Civil 3D objects and so on. I want to redefine explode so that the only objects that can be exploded are blocks and polylines. I managed to get it working, but it only selects one object. When I select more than one object it only explodes the last object selected.

How do I make the lisp explode multiple polylines or blocks?

 

(command "UNDEFINE" "EXPLODE")
;undefine the Explode command

(setq echo (getvar "cmdecho"))
(setvar "cmdecho" 0)

(defun C:EXPLODE (/ blpl echo)

(alert "\nYou are ONLY allowed to explode blocks or polylines\n\nContact CAD Manager if you have questions")
;inform the user

(prompt "\nSelect a Block or Polyline: ")      

(setq blpl (ssget '((-4 . "<OR")(0 . "INSERT")(0 . "LWPOLYLINE")(-4 . "OR>"))))
(command ".EXPLODE" blpl)
;explode the object

(princ)
;finish clean

);defun

(setvar "cmdecho" echo)
;restore cmdecho

 

You're generous .. I wouldn't let them explode my blocks! :)

  • Like 1

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...