TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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:
(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.
-
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.
-
There is a lot of information here on
Explode Blocks (http://www.theswamp.org/index.php?action=search2;params=YWR2YW5jZWR8J3wxfCJ8YnJkfCd8MiwxMXwifHNob3dfY29tcGxldGV8J3x8InxzdWJqZWN0X29ubHl8J3x8Inxzb3J0X2RpcnwnfGRlc2N8Inxzb3J0fCd8cmVsZXZhbmNlfCJ8c2VhcmNofCd8XCJleHBsb2RlIGJsb2Nrc1wi)
-
...
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.
-
Select All Blocks (Inserts):
(ssget "_X" '((0 . "INSERT")))
-
Select All Blocks (Inserts):
(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:
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.
-
Current Layout:
(ssget "_X" (list (cons 0 "INSERT")
(cons 410 (getvar 'CTAB))))
-
How are you defining 'blocks
in this (command ".explode" blocks "")
See if this helps ;
(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)
(foreach ent (kdub:ss->entlist SelectedBlocksInCurrentSpace)
(command ".explode" ent )
)
(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
)
)
-
Kerry,
my definition is simply:
(setq blocks (ssget "_X" '((0 . "INSERT"))))
So, let me throw in the (list (cons ... )) and I'll let you know.
-
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.
-
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.
-
Set QAFLAGS to 1 perhaps?
< Note:- this should only be changed within the routine, and then reset when the routine completes >
-
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 ??
(setq dwgblocks (ssget "_X" '((0 . "INSERT")(0 . "MText,Text"))))
Thanks guys.
-
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.
-
Well, whatever QAFLAGS is, it didn't do the trick.
I received a return value of: 0 Nothing exploded, no other prompt.
-
QAFLAGS is undocumented. It's been in AutoCAD since R11.
-
QAFLAGS normally affects whether selection sets can be exploded. :-)
-
Maybe:
(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)
)
-
Another one to try.
(defun c:test (/ ss)
(if (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 410 (getvar 'CTAB)))))
(progn
(initcommandversion 2)
(command "._explode" "P" "")
)
)
(princ)
)
-
Last one:
(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)
)
-
CAB,NICE
HAPPY NEW YEAR!
-
yep, that last one should do nicely Alan
Should ignore locked layers too, yes ?
-
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.
-
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........
-
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:
No more time tonight..
LiZZZZPPLiZZZZPPLiZZZZZZZzzzzzzppp........
:)
Nicely done.