TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Hangman on February 19, 2010, 01:18:59 PM

Title: Seeing info of selection sets
Post by: Hangman on February 19, 2010, 01:18:59 PM
Alright, this is a stupid question but for the life of me I can't remember how to view the info after making a selection set.
So I have the following code:

Code: [Select]
(setq dwgblocks (ssget "X" '((2 . "*"))))
because I'm simply trying to select all the blocks in a drawing so I can explode them all.

But I know this is selecting everything including the stuff in paperspace, and I only want the stuff in modelspace.
So, first off, how can I view this information from the selection set ??
Secondly, does anyone have an idea for how I can select just the blocks in modelspace ??

Thanks in advance.
Title: Re: Seeing info of selection sets
Post by: T.Willey on February 19, 2010, 01:27:09 PM
ssnamex will list the selection set properties.  Read help for all the information.

To get certain entities, use there dxf codes.  For blocks, inserts, use dxf code 0 and insert.

To get items in a certain tab, use code 410 and that spaces name.

Hope that helps.

ps... code 2 gets names of entities, that have names.
Title: Re: Seeing info of selection sets
Post by: CAB on February 19, 2010, 01:56:49 PM
There is a lot of information here on
Explode Blocks (http://www.theswamp.org/index.php?action=search2;params=YWR2YW5jZWR8J3wxfCJ8YnJkfCd8MiwxMXwifHNob3dfY29tcGxldGV8J3x8InxzdWJqZWN0X29ubHl8J3x8Inxzb3J0X2RpcnwnfGRlc2N8Inxzb3J0fCd8cmVsZXZhbmNlfCJ8c2VhcmNofCd8XCJleHBsb2RlIGJsb2Nrc1wi)
Title: Re: Seeing info of selection sets
Post by: Hangman on February 19, 2010, 04:29:39 PM
...
ps... code 2 gets names of entities, that have names.
T,
I was to the understanding I could use ... '((2 . "*")) to get blocks and just use the wildcard to select all the blocks in the drawing.  I know it made a selection set for me, but I couldn't for the life of me figure out how to read it.  :D
But if this is not the case, how would you suggest selecting all the blocks in a drawing in model space only to be exploded ??
I'm converting a boat load of drawings from Microstation to CAD so I need to change ALL the attributes, text styles, colors, layers, etc.   We're spending hours on something that should take a mere minutes.
By the way T, it's good to see you again, I've been out of the loop for the past year.
Title: Re: Seeing info of selection sets
Post by: Lee Mac on February 19, 2010, 04:32:28 PM
Select All Blocks (Inserts):

Code: [Select]
(ssget "_X" '((0 . "INSERT")))
Title: Re: Seeing info of selection sets
Post by: Hangman on February 19, 2010, 05:08:26 PM
Select All Blocks (Inserts):

Code: [Select]
(ssget "_X" '((0 . "INSERT")))
OK, it selects some objects, I still do not know what it is putting in the selection set though.
When I run the command to explode the blocks, I get the following error:
Quote
Command: (command ".explode" blocks "")
.explode
Select object:
The object is not in current space.

The object is not in current space.

The object is not in current space.

The object is not in current space.

The object is not in current space.

The object is not in current space.

The object is not in current space.

The object is not in current space.

The object is not in current space.

The object is not in current space.
Now, I have one block in Paper space (a title block), the rest are in model space.  These in model space are the ones I want to explode.
Title: Re: Seeing info of selection sets
Post by: Lee Mac on February 19, 2010, 05:33:05 PM
Current Layout:

Code: [Select]
(ssget "_X" (list (cons 0 "INSERT")
                  (cons 410 (getvar 'CTAB))))
Title: Re: Seeing info of selection sets
Post by: Kerry on February 19, 2010, 05:45:59 PM
How are you defining 'blocks
in this  (command ".explode" blocks "")



See if this helps ;
Code: [Select]
(setq SelectedBlocks(ssget "_X" '((0 . "INSERT") )))
(kdub:ss->entlist SelectedBlocks)


(setq SelectedBlocksInCurrentSpace (ssget "_X"
                                        (list (cons 0 "INSERT")
                                              (cons 410 (getvar 'CTAB))
                                        )
                                 )
)
(kdub:ss->entlist SelectedBlocksInCurrentSpace)

Code: [Select]
(foreach ent (kdub:ss->entlist SelectedBlocksInCurrentSpace)
         (command ".explode" ent )
)

Code: [Select]
(defun kdub:ss->entlist (ss / i returnval)
  (if (and ss (< 0 (sslength ss)))
    (progn (setq i 0)
           (repeat (sslength ss)
             (setq returnval (cons (ssname ss i) returnval)
                   i         (1+ i)
             )
           )
    )
  )
  (if returnval
    (reverse returnval)
    nil
  )
)
Title: Re: Seeing info of selection sets
Post by: Hangman on February 19, 2010, 05:59:15 PM
Kerry,
my definition is simply:
Code: [Select]
(setq blocks (ssget "_X" '((0 . "INSERT"))))So, let me throw in the  (list (cons ...  )) and I'll let you know.
Title: Re: Seeing info of selection sets
Post by: T.Willey on February 19, 2010, 06:58:55 PM
There is no need to explode each entity by itself, so I would use the code Lee posted, and pass that selection set to the explode command, and then keep going until there is no blocks left.

Good to see you too Hangman.
Title: Re: Seeing info of selection sets
Post by: Kerry on February 19, 2010, 07:07:26 PM
There is no need to explode each entity by itself, so I would use the code Lee posted, and pass that selection set to the explode command, and then keep going until there is no blocks left.

Good to see you too Hangman.

I couldn't get that to work Tim. Only exploded the first item in the selection set ... or that seemed to be the case.
Title: Re: Seeing info of selection sets
Post by: Lee Mac on February 19, 2010, 07:12:36 PM
Set QAFLAGS to 1 perhaps?

< Note:- this should only be changed within the routine, and then reset when the routine completes >
Title: Re: Seeing info of selection sets
Post by: Hangman on February 19, 2010, 07:15:36 PM
There is no need to explode each entity by itself, so I would use the code Lee posted, and pass that selection set to the explode command, and then keep going until there is no blocks left.

Good to see you too Hangman.

I couldn't get that to work Tim. Only exploded the first item in the selection set ... or that seemed to be the case.

I couldn't get it to work either.  It asks for the name of the block to be exploded.  I'm assuming it's because the list is created but I'm not sure.
Question along these lines then:   Can I filter the selection to only blocks with text in them ??  And would that look something like this ??
Code: [Select]
(setq dwgblocks (ssget "_X" '((0 . "INSERT")(0 . "MText,Text")))) Thanks guys.
Title: Re: Seeing info of selection sets
Post by: Hangman on February 19, 2010, 07:17:20 PM
Set QAFLAGS to 1 perhaps?

What is QAFLAGS ??  I can't find it in the system variables or the in help file for that matter.
Title: Re: Seeing info of selection sets
Post by: Hangman on February 19, 2010, 07:23:17 PM
Well, whatever QAFLAGS is, it didn't do the trick.
I received a return value of:  0   Nothing exploded, no other prompt.
Title: Re: Seeing info of selection sets
Post by: Kerry on February 19, 2010, 07:28:06 PM

QAFLAGS is undocumented. It's been in AutoCAD since R11.

Title: Re: Seeing info of selection sets
Post by: Lee Mac on February 19, 2010, 07:45:32 PM
QAFLAGS normally affects whether selection sets can be exploded.  :-)
Title: Re: Seeing info of selection sets
Post by: CAB on February 19, 2010, 08:53:11 PM
Maybe:
Code: [Select]
(defun c:test (/ usrexplmode ent ss)
  (if (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 410 (getvar 'CTAB)))))
    (progn
      (setq usrexplmode (getvar "explmode"))
      (setvar "explmode" 1)
      (mapcar '(lambda(x)(command "._explode" x)) (mapcar 'cadr (ssnamex ss)))
      (setvar "explmode" usrexplmode)
    )
  )
  (princ)
)
Title: Re: Seeing info of selection sets
Post by: CAB on February 19, 2010, 08:59:33 PM
Another one to try.
Code: [Select]
(defun c:test (/ ss)
  (if (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 410 (getvar 'CTAB)))))
    (progn
      (initcommandversion 2)
      (command "._explode" "P" "")
    )
  )
  (princ)
)
Title: Re: Seeing info of selection sets
Post by: CAB on February 19, 2010, 09:08:06 PM
Last one:
Code: [Select]
(defun C:test (/ ss flag)
  (if (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 410 (getvar 'CTAB)))))
    (progn
      (setq flag (getvar "qaflags"))
      (setvar "qaflags" 5)
      (command "explode" ss "")
      (setvar "qaflags" flag)
    )
  )
  (princ)
)

Title: Re: Seeing info of selection sets
Post by: myloveflyer on February 19, 2010, 09:17:58 PM
CAB,NICE
HAPPY NEW YEAR!
Title: Re: Seeing info of selection sets
Post by: Kerry on February 19, 2010, 09:28:22 PM

yep, that last one should do nicely Alan

Should ignore locked layers too, yes ?
Title: Re: Seeing info of selection sets
Post by: T.Willey on February 19, 2010, 10:04:36 PM
Wow.  Learned something new.  I could have sworn that I used a selection set with the explode command before.  Guess I remembered wrong.  Good to know.
Title: Re: Seeing info of selection sets
Post by: CAB on February 19, 2010, 11:13:39 PM

yep, that last one should do nicely Alan

Should ignore locked layers too, yes ?


Thanks all,

It honered locked layers in ACAD2000.
I could not test the middle one because initcommandversion is not recognized in ACAD 2000.
No more time tonight..
ZZZZZZZZZZZZZZZzzzzzz........
Title: Re: Seeing info of selection sets
Post by: Hangman on February 21, 2010, 11:12:25 AM
Thanks all,

It honered locked layers in ACAD2000.
I could not test the middle one because initcommandversion is not recognized in ACAD 2000.
No more time tonight..
ZZZZZZZZZZZZZZZzzzzzz........
I think the correct phrase would be something to the effect of:
Quote
No more time tonight..
LiZZZZPPLiZZZZPPLiZZZZZZZzzzzzzppp........
  :)
Nicely done.