Print Page | Close Window

Explode only polyline

Printed From: CAD Forum
Category: EN
Forum Name: AutoCAD
Forum Description: Discussion about AutoCAD and AutoCAD LT, viewers, DWG and DWF formats, Design Review, AutoCAD 360, add-ons
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=10966
Printed Date: 20.May.2026 at 06:43


Topic: Explode only polyline
Posted By: marian1autocad
Subject: Explode only polyline
Date Posted: 06.Feb.2015 at 19:38
Hi everyoane,

I have a drawing in Autocad that contains lines, text, block reference, mtext and polylines.

In this drawing with Autolisp i want to do next:

1. select all polylines
2. explode them

I made, and i run this in Autocad but it doesn't work:

(setq pl (ssget "X" '((0 . "LWPOLYLINE"))))
(command "explode" pl)

What is wrong in my syntax?

How can i select all polylines from a drawing, and than to explode them?


Any help is appreciated.

Thank you very much!



Replies:
Posted By: Kent Cooper
Date Posted: 06.Feb.2015 at 19:54
For some reason I've never seen explained, the Explode command in particular cannot Explode more than one thing at a time in a (command) function.  There are at least two things you can do:  1) Step through the selection set and Explode each one individually, or 2) Mess around with the mysterious and undocumented QAFLAGS System Variable.  If you Search for QAFLAGS in the AutoDesk Customization Forum, http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bd-p/130" rel="nofollow - http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bd-p/130 , you'll find various threads that talk about it and show you how to change the setting [and be sure to change it back!].


Posted By: marian1autocad
Date Posted: 06.Feb.2015 at 21:08
I will search for QAFLAGS in the AutoDesk Customization Forum and i will see what advantage can bring. Big smile

Thank you Kent Cooper for your help and for your time spent here for my probleme! I appreciate.


Posted By: criecky
Date Posted: 08.Feb.2015 at 09:49
hi, use

(defun c:polyexplo (/ pl)
(setq pl (ssget "X" '((0 . "POLYLINE"))))
(command "_explode" pl)
)



Posted By: marian1autocad
Date Posted: 08.Feb.2015 at 20:47
Originally posted by criecky criecky wrote:

hi, use

(defun c:polyexplo (/ pl)
(setq pl (ssget "X" '((0 . "POLYLINE"))))
(command "_explode" pl)
)



I tried your proposal and it did not work. Thank you Criecky!

Any suggestion are welcom.


Posted By: marian1autocad
Date Posted: 08.Feb.2015 at 21:37
Originally posted by Kent Cooper Kent Cooper wrote:

For some reason I've never seen explained, the Explode command in particular cannot Explode more than one thing at a time in a (command) function.  There are at least two things you can do:  1) Step through the selection set and Explode each one individually, or 2) Mess around with the mysterious and undocumented QAFLAGS System Variable.  If you Search for QAFLAGS in the AutoDesk Customization Forum, http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bd-p/130" rel="nofollow - http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bd-p/130 , you'll find various threads that talk about it and show you how to change the setting [and be sure to change it back!].



Kent Cooper gave me the solution
for my problem, and i want to thank him very much.

I set QAFLAGS variable to 1 (0 is default value) and after that my syntax works well. Big smile



My syntax now will be:

(setq a (getvar "qaflags"))

(setq b (setvar "qaflags" 1))

(setq pl (ssget "X" '((0 . "LWPOLYLINE"))))

(command "explode" pl "")

(setvar "qaflags" a)



Here (  http://www.manusoft.com/resources/acadexposed/sysvars.html" rel="nofollow - http://www.manusoft.com/resources/acadexposed/sysvars.html   ) i found this:

QAFLAGS bitcode 0 - 32767* R11 bit 0 (1) : ^C in menu macro cancels grips (acts like keyboard <Esc>).
bit 1 (2) : no pause during text screen listings.
bit 2 (4) : no "alert" dialogs (text display instead).
bit 7 (128) : accepts "screen picks" (point lists) via (command) function.
*Note that this was an integer with range -32768 - 32767 in R11, then it changed to 0 - 32767 in R12.[2]

My problem is now solved and this topic should be closed!

Thank you Kent Cooper for your help!
Big smile


Posted By: Vladimir Michl
Date Posted: 08.Feb.2015 at 22:25
But this is the official way to do that:
 
(setq pl (ssget "_X" '((0 . "LWPOLYLINE"))))
(initcommandversion 2)
(command "_explode" pl "")


-------------
Vladimir Michl (moderator)
ARKANCE - https://arkance.world" rel="nofollow - https://arkance.world - Autodesk Platinum Partner


Posted By: Kent Cooper
Date Posted: 09.Feb.2015 at 15:47
Originally posted by Vladimir Michl Vladimir Michl wrote:

But this is the official way to do that:
.... (initcommandversion 2) ....
 
... if you have a new-enough version of AutoCAD [I'm not sure in which version that was introduced].  Is the 2 there calling for a newer version of Explode that, inside a (command) function, can work with a selection set of more than one object?  If so, that would also require a new-enough version of AutoCAD.


Posted By: Kent Cooper
Date Posted: 09.Feb.2015 at 15:51
Originally posted by criecky criecky wrote:

hi, use

(defun c:polyexplo (/ pl)
(setq pl (ssget "X" '((0 . "POLYLINE"))))
(command "_explode" pl)
)

 
The reason that doesn't work is that the only difference from the code in the first Post [other than the (defun) wrapping] is the entity type in the selection-set filter.  It will find "heavy" 2D Polylines and 3D Polylines, but not LightWeight Polylines, and it will have the same problem with the Explode command and a multiple-object selection set.



Print Page | Close Window