Display full version of the post: Explode only polyline

marian1autocad
06.02.2015, 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 polylines2. explode themI 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!

Kent Cooper
06.02.2015, 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, you'll find various threads that talk about it and show you how to change the setting [and be sure to change it back!].

marian1autocad
06.02.2015, 21:08
I will search for QAFLAGS in the AutoDesk Customization Forum and i will see what advantage can bring. Thank you Kent Cooper for your help and for your time spent here for my probleme! I appreciate.

criecky
08.02.2015, 09:49
hi, use(defun c:polyexplo (/ pl)(setq pl (ssget "X" '((0 . "POLYLINE"))))(command "_explode" pl))

marian1autocad
08.02.2015, 20:47
[QUOTE=criecky]hi, use(defun c:polyexplo (/ pl)(setq pl (ssget "X" '((0 . "POLYLINE"))))(command "_explode" pl))[/QUOTE]I tried your proposal and it did not work. Thank you Criecky!Any suggestion are welcom.

marian1autocad
08.02.2015, 21:37
[QUOTE=Kent Cooper]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, you'll find various threads that talk about it and show you how to change the setting [and be sure to change it back!].[/QUOTE]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. 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  ) 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!

Vladimir Michl
08.02.2015, 22:25

But this is the official way to do that: [CODE](setq pl (ssget "_X" '((0 . "LWPOLYLINE"))))(initcommandversion 2)(command "_explode" pl "")[/CODE]

Kent Cooper
09.02.2015, 15:47
[QUOTE=Vladimir Michl] But this is the official way to do that:
.... (initcommandversion 2) ....
[/QUOTE]
 
... 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.Kent Cooper2015-02-09 15:52:18

Kent Cooper
09.02.2015, 15:51
[QUOTE=criecky]hi, use(defun c:polyexplo (/ pl)(setq pl (ssget "X" '((0 . "POLYLINE"))))(command "_explode" pl))[/QUOTE]
 
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.