PDA

View Full Version : Explode in LISP Does Not Explode Selection Set



Kevin Janik
2004-12-07, 05:17 PM
I just wrote a piece of lisp to add to another program that creates a selection set of all the objects on a certain layer and then I use the Explode command to explode them all at once. In LISP the routine only explodes one of the object not all of them. If I type Explode at the command line in AutoCAD 2004 and at the "Select objects" prompt to give it the :sset selection set I created in the LISP routine using !:sset it explodes all of the objects of the selection set.

What is the deal?

The program is below.

(defun C:XE ( / :SSET)
(setq :SSET (ssget "X" '((0 . "INSERT")(8 . "EXPLODE"))))
(command "explode" :SSET "")
);end defun

Kevin

rad.77676
2004-12-07, 05:39 PM
Kevin,
Take a look at this, it may help!


(SETQ SS1 (ssget ;GET ALL WATER LAT'S AND PIPES
'((0 . "LINE")
(-4 . "<OR")
(8 . "WTR-P-PIPE")
(8 . "WTR-P-LAT")
(-4 . "OR>")
)
)
)
(COMMAND "ZOOM" "E" "")
(IF (/= SS1 NIL)
(PROGN (SETQ LNGTH (SSLENGTH SS1)) ;LENGTH OF SELECTION SET (SS1)
(SETQ INDEX 0) ;SET INDEX TO ZERO
(REPEAT LNGTH ;REPEAT FOR EACH WATER LINE
(SETQ ENT1 (ENTGET (SSNAME SS1 INDEX))) ;GET WATER LINE
(SETQ ENTTYPE (CDR (ASSOC 0 ENT1))) ;GET ENTITY TYPE
(IF (= ENTTYPE "LINE") ;IF ENTITY IS A LINE
(PROGN (SETQ PT1 (TRANS (CDR (ASSOC 10 ENT1)) 0 1))
;PROGN/GET 1ST ENDPOINT
(SETQ PT2 (TRANS (CDR (ASSOC 11 ENT1)) 0 1))
;GET 2ND ENDPOINT
(SETQ PNTS (LIST PT1 PT2)) ;LIST BOTH POINTS
(SETQ INDEX (+ INDEX 1)) ;INDEX +1
)
)
(STM_WTR)
(SAN_WTR)
(SAN_LAT)
)
)
)

Mike.Perry
2004-12-07, 05:49 PM
Hi

Below comes via an old LISP Guild posts -

-----Original Message-----
From: owner-guild-lisp@augi.com [mailto:owner-guild-lisp@augi.com] On Behalf Of dyoung@mcwi.com
Sent: 08 November 2002 00:26
To: Cynthia Hadley; Augi-Lsip Guild (E-mail)
Subject: Re: [LISP] Explode Selection Set

(setq myss (ssget "x" '((0 . "POLYLINE,LWPOLYLINE")))) (setvar "qaflags" 1) (command "explaode" myss "") (setvar "qaflags 0)

The reason Explode only explodes the one entity in the selection set is because years ago (r10 era I think) the explode command would only work on one entity at a time. This behavior is to preserve functionality of older legacy AutoLISP programs.

You can work around it as I showed above with the help of the undocumented QAFLAGS system variable.


-----Original Message-----
From: owner-guild-lisp@augi.com [mailto:owner-guild-lisp@augi.com]On
Behalf Of R. Robert Bell
Sent: 31 July 2002 21:08
To: Lisp Guild
Subject: Re: [LISP] Date: Thu, 1 Aug 2002 07:56:08 +1200

Because Autodesk programmed it that way... BwaHaHa!

Set the undocumented setvar QAFlags to 1 before the explode, then back to 0 afterwards.

R. Robert Bell, MCSE
AUGI Guild Moderator
www.AcadX.com


-----Original Message-----
From: owner-guild-lisp@augi.com [mailto:owner-guild-lisp@augi.com]On
Behalf Of Peter Jamtgaard
Sent: 31 July 2002 21:53
To: guild-lisp@augi.com
Subject: RE: [LISP] Date: Thu, 1 Aug 2002 07:56:08 +1200

Kelvyn,

It has to do with the evolution of the explode command. The default method of the explode command from within LISP is one item at a time, like it was when the explode command came out around release 9.

If you iterate through your selection set it can explode them one at a time.

Peter Jamtgaard


(if SSGRD
(progn
(setq CNT 0)
(repeat (sslength SSGRD)
(vl-cmdf "._explode" (ssname SSGRD CNT))
(setq CNT (1+ CNT))
)
)
)

Have a good one, Mike

Jeff_M
2004-12-07, 06:02 PM
You can reset the "QAFLAGS" sysvar to 5 and it will allow the "explode" to work as expected in lisp:


(defun C:XE ( / :SSET)
(setq flag (getvar "qaflags"))
(setvar "qaflags" 5)
(setq :SSET (ssget "X" '((0 . "INSERT")(8 . "EXPLODE"))))
(command "explode" :SSET "")
(setvar "qaflags" flag)
(princ)
);end defun

Kevin Janik
2004-12-07, 06:45 PM
Thanks for the great, quick help!

One post said to set "qaflags" to 1 and another to "5". Does the number matter? "1" worked great!

Thanks again!

Kevin

kennet.sjoberg
2004-12-07, 10:10 PM
QAFLAGS bitcode, introduced in R11, an integer range from -32768 to +32767,
changed to 0 - 32767 in R12.

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.
bit 9 (512) : sets Bind type to insert in R14

I do not know why it helps You exploding things...
but the main thing is that bit 0 (1) is set. (setvar "QAFLAGS" 1 )

: ) Happy Computing !

kennet