Can you pls help the following
I want to explode all blocks except one block (for ex: - block name “TTL”)
I have been tried like this way but its not working
(SSGET “_X” ((0 . “INSERT”) (-4 . “/=”) (2 . “TTL”)))
(i-e) select all block which name not equal to “TTL”
Regards,
arun
Solved! Go to Solution.
Solved by Gary_J_Orr. Go to Solution.
@arunpdms wrote:Can you pls help the following
I want to explode all blocks except one block (for ex: - block name “TTL”)
I have been tried like this way but its not working
(SSGET “_X” ((0 . “INSERT”) (-4 . “/=”) (2 . “TTL”)))
(i-e) select all block which name not equal to “TTL”
Regards,
arun
(SSGET “_X” '((0 . “INSERT”) (-4 . “<NOT”) (2 . “TTL”) (-4 . “NOT>”) ))
Also notice the single quote ( ' ) at the beginning of the filter list to define the contents as a list.
But be aware, you are selecting all blocks in the database in every tab... if you are passing it to a command function this will be ok since the command will filter out objects not in the current space, but if you are doing the explode via other means then you could have unintended results...
whereas this will ensure that your selectionset only returns entities in your current layout tab (in this example I have replaced a direct quote of the list with the list function so I can pass in a variable):
(SSGET “_X” (list (0 . “INSERT”) (410 . (getvar "ctab")) (-4 . “<NOT”) (2 . “TTL”) (-4 . “NOT>”) ))
-G
@Anonymous wrote:
....whereas this will ensure that your selectionset only returns entities in your current layout tab ....:
(SSGET “_X” (list (0 . “INSERT”) (410 . (getvar "ctab")) (-4 . “<NOT”) (2 . “TTL”) (-4 . “NOT>”) ))
I believe that needs to be:
(SSGET "_X" (list '(0 . "INSERT") (cons 410 (getvar "ctab")) '(-4 . "<NOT") '(2 . "TTL") '(-4 . "NOT>") ))
@Anonymous wrote:
Thank you for the catch Kent... ....
I have become sensitive to that little detail as a result of having made the same mistake myself several times.
The OP might also want to be aware of a peculiarity with Exploding using a (command) function. Unless you take appropriate measures, it won't Explode a whole selection set at once, the way it will do all sorts of [maybe all?] other editing commands to a whole set together. You need to either mess with the mysterious and undocumented QAFLAGS System Variable [do a Search] to allow it to do so, or step through the set and Explode each Block separately. Either way, if they may exist in more than one drawing space [model space and/or possibly more than one paper-space layout], and you want to Explode them in all spaces, omitting the filtering with the 410 entry in the (ssget) filter, you will need to be in the space of each Block to Explode it/them with (command "_.explode" ...). You can do that by stepping through and doing
(setvar 'ctab (cdr (assoc 410 GetTheBlockEntityDataList)))
for each before Exploding it. There's probably also a (vl...) approach, too, that others will be able to describe right off but that I don't know well enough.
@Kent1Cooper wrote:
@Anonymous wrote:
Thank you for the catch Kent... ....I have become sensitive to that little detail as a result of having made the same mistake myself several times.
The OP might also want to be aware of a peculiarity with Exploding using a (command) function. Unless you take appropriate measures, it won't Explode a whole selection set at once, the way it will do all sorts of [maybe all?] other editing commands to a whole set together. You need to either mess with the mysterious and undocumented QAFLAGS System Variable [do a Search] to allow it to do so, or step through the set and Explode each Block separately. Either way, if they may exist in more than one drawing space [model space and/or possibly more than one paper-space layout], and you want to Explode them in all spaces, omitting the filtering with the 410 entry in the (ssget) filter, you will need to be in the space of each Block to Explode it/them with (command "_.explode" ...). You can do that by stepping through and doing
(setvar 'ctab (cdr (assoc 410 GetTheBlockEntityDataList)))
for each before Exploding it. There's probably also a (vl...) approach, too, that others will be able to describe right off but that I don't know well enough.
All good advice Kent. Although...
If you grab a selset without filtering for the current space it will return a sel set that may not have any "viable" entities in it (viable defined as within the current layout and passable to the command function), so, when stepping through the selset some command calls will fail... your suggestion to resolve that by switching to the space of the returned entity could end up with a lot of tab switching depending on the order of the return set...
If you truly want to perform a command (or some other function that is dependant on the entity being in the current space) on all entities on all tabs: It would be more efficient to switch to each tab, filter for entities on that tab, do the work, step to the next tab, repeat until no more tabs...
-G
Gary_J_Orr wrote
:.... your suggestion to resolve that by switching to the space of the returned entity could end up with a lot of tab switching depending on the order of the return set...
If you truly want to perform a command ... on all entities on all tabs: It would be more efficient to switch to each tab, filter for entities on that tab, do the work, step to the next tab, repeat until no more tabs...
....
Yes, although that approach has its own potential drawback, namely that it might have to work its way through a bunch of tabs that don't have any such Blocks in them. I guess it depends on how many tabs there are, relative to how many are likely to contain things it needs to process, and how many such things there are likely to be. If quantities of either or both objects and tabs are big enough, and if it takes a noticeably long time to make tab switches, it might be worth considering this, to avoid going into tabs it doesn't need to: step through the selection and find the tab each object is in, making a list of just those tab names that do contain such objects, and then move in turn into each of those tabs only, and find and process the objects in each. But that involves both an intial overall (ssget) and another in each tab, as well as the making of the list of tabs, so maybe not....
thanks for your response.
so how the routine need to be instead of this following code:
i am a learner.
(defun c:sdf()
(SETQ fgh (SSGET "_X" (list '(0 . "INSERT") (cons 410 (getvar "ctab")) '(-4 . "<NOT") '(2 . "TTL") '(-4 . "NOT>") )) )
(Command "EXPLODE" fgh ) )
@arunpdms wrote:
thanks for your response.
so how the routine need to be instead of this following code:
i am a learner.
(defun c:sdf()
(SETQ fgh (SSGET "_X" (list '(0 . "INSERT") (cons 410 (getvar "ctab")) '(-4 . "<NOT") '(2 . "TTL") '(-4 . "NOT>") )) )
(Command "EXPLODE" fgh ) )
something like this (and just keeping it simple and ignoring the discussion that we have fired off about process):
(defun c:sdf() (if (SETQ fgh (SSGET "_X" (list '(0 . "INSERT") (cons 410 (getvar "ctab")) '(-4 . "<NOT") '(2 . "TTL") '(-4 . "NOT>") ))) (progn (setq cntr 0) (while (< cntr (sslength fgh)) (command "_.Explode" (ssname fgh cntr)) ;catch the possibility of it being an xref or ;non explodable block which would leave the cmd active (if (> (getvar "cmdactive") 0) (command "") );if not explodable (setq cntr (1+ cntr)) );while );progn have selset True );If selset is created );defun
-Gary
Just to share another way to filter the block name, and another way to use the Explode command with a selection set, without modifying the QAFLAGS SysVar
(defun c:sdf( / fgh) (if (setq fgh (ssget "_X" (list '(0 . "INSERT") (cons 410 (getvar "ctab"))'(2 . "~TTL")))) (progn (initcommandversion) (command "_.explode" fgh "") ) ) (princ) )
Henrique
@hmsilva wrote:
Just to share another way to filter the block name, and another way to use the Explode command with a selection set, without modifying the QAFLAGS SysVar
.... (initcommandversion) (command "_.explode" fgh "") ....
Nice to know it's possible without dealing with QAFLAGS, but (initcommandversion) is a function that must have come along in a more recent version than the ol' 2004 I'm stuck with here [I have access to a newer one elsewhere]. So anyone with an old-enough version would be limited to the other approaches already discussed, unless there's yet another way with something like (vl-something-or-other...).
@Kent1Cooper wrote:
Nice to know it's possible without dealing with QAFLAGS, but (initcommandversion) is a function that must have come along in a more recent version than the ol' 2004 I'm stuck with here [I have access to a newer one elsewhere]. So anyone with an old-enough version would be limited to the other approaches already discussed, unless there's yet another way with something like (vl-something-or-other...).
True, initcommandversion function start in AC2010...
And another way would be using vla-explode...
Henrique