Display full version of the post: Select list of blocks from specific layers

callvey
04.04.2013, 21:10
HiI have been trying to achieve this all day using filters and a vba macro I found online but its turning out to be a lot harder than I first thought.I am trying to select a list of blocks (89 in total) that sit on 4 different layers in a drawing and put them on a new layer that I have already created.Is this something that can be done through a macro or shall I just bite the bullet and get stuck in manually??Any guidance please?ThanksTom

CarlB
04.04.2013, 22:57

Did you try the "SSX" command (Express Tools)?Should work ok, if you don't have a long list of block names. 

heinsite
05.04.2013, 09:23
Experiment with SELECTSIMILAR.  You can tweak the settings to include pretty much the specificity you need.Dave.

callvey
05.04.2013, 10:34
Thanks for your replies.Unfortunately both methods ssx and select similar do not work as there are more objects on the 4 layers other than the blocks I want to select.I think my only option would be to use a macro to do this.Many thanksTom

John Connor
05.04.2013, 11:40
It sounds more like you need a custom lisp routine not a macro.

callvey
05.04.2013, 11:44
Do you know of an example script that i can analyse please.Thanks 

heinsite
05.04.2013, 12:23
And QSELECT didn't work for you either?Dave.

CarlB
05.04.2013, 17:28

I believe SSX doesn't work because it allows only a single block name & a single layer for a selection filter.A lisp routine may be not difficult, how many different blocks are you selecting, and would you want to enter name or select them?

Kent Cooper
05.04.2013, 20:20
There may be a limit on string length that would prevent listing all 89 Block names in one run, in which case you might need to break it down, but you can find multiple Blocks on multiple Layers in one (ssget) function, with comma-delimited lists:
(ssget "_X" '((2 . "Block1,Block2,Block3") (8 . "Layer1,Layer2,Layer3")))
 
Depending on how the Block names vary, you could possibly shorten it with wildcards the same as can be used in (wcmatch).

callvey
09.04.2013, 17:16
That works Kent thanks!How do I use this in a lisp I have this but it doesn't work?(defun BS1 ()(ssget "x" '((8 . "fxpm,fxw,fxdt,ardt")(2 .  "4plug,CP-CAB-TRANSACTION,04-INKCORRAL-CHECKOUT-2-L,04-INKCORRAL-CHECKOUT-2-R,04-INKCORRAL-CHECKOUT-L,04-INKCORRAL-CHECKOUT-R,2PLUG,3PLUG,6plug,AMAZON-LOCKER-08,AMAZON-LOCKER-10,CP-CAB-LIVEBAR,AMAZON-LOCKER-11,AMAZON-LOCKER-13,AMAZON-LOCKER-14,BALER-1800HD,BALER-360,BC-COUNTER-CONSULT-96,BC-COUNTER-CONSULT-96-L,BC-COUNTER-CONSULT-96-R,BC-COUNTER-POS-L-108,BC-COUNTER-POS-R-108,BC-COUNTER-SHIP-L-76,BC-COUNTER-SHIP-R-76,BR17-NPC,BT-ANSWER-BAR-3,BT-CAB-ANSWER-BAR,BT-CAB-ANSWER-BAR-2,BT-CAB-CELLBAR,BT-CORE-GRAPHICS-22,BT-COUNTER-CONSULT-96,BT-COUNTER-POS-L-108,BT-COUNTER-POS-R-108,BT-EREADERS-TABLETS,CC-AM-48,CC-CAT105,CC-CS10-SSC-CABINET,CC-HPZ2100-24,CC-HPZ2100-44,CC-HSB,CC-HSC,CC-KM4850,CC-LFB,CC-LFC,CC-MEDIA-360")))

callvey
09.04.2013, 20:01
I am selecting 89 blocks from 4 different layers.I have to do this because the blocks exist on other layers that i do not want to select, these blocks also have xdata.i would want to enter name them.

CarlB
09.04.2013, 21:27

I suggest the lisp code be modified to allow you to work with the selection, assuming it works:(defun C:BS ()  (setq bset (ssget "x" .....etc...)));;end defun This routine is executed by typing "BS" on the command line.Selection set of blocks now assigned to the variable "bset". Manipulate this set as you would for other selection set; to include the selection set from the lisp routine use "!bset" (exclamation point then variable name) on the command line when prompted to select objects.

CarlB
10.04.2013, 01:59

Try the following routine. It selects all blocks on the 4 layers you noted; looks at each, if name matches list it is moved to new layer you provide oin the routine. [code](defun C:BS1 ()   (ssget "x" '((8 . "fxpm" "fxw" "fxdt" "ardt")))   (setq NewLayer "$$layer_Name$$");;put your new layer name here in quotes   (setq block_list '("4plug" "CP-CAB-TRANSACTION" "04-INKCORRAL-CHECKOUT-2-L" "04-INKCORRAL-CHECKOUT-2-R" "04-INKCORRAL-CHECKOUT-L"                    "04-INKCORRAL-CHECKOUT-R" "2PLUG" "3PLUG" "6plug" "AMAZON-LOCKER-08" "AMAZON-LOCKER-10" "CP-CAB-LIVEBAR" "AMAZON-LOCKER-11"                     "AMAZON-LOCKER-13" "AMAZON-LOCKER-14" "BALER-1800HD" "BALER-360" "BC-COUNTER-CONSULT-96" "BC-COUNTER-CONSULT-96-L"                    "BC-COUNTER-CONSULT-96-R" "BC-COUNTER-POS-L-108" "BC-COUNTER-POS-R-108" "BC-COUNTER-SHIP-L-76" "BC-COUNTER-SHIP-R-76"                    "BR17-NPC" "BT-ANSWER-BAR-3" "BT-CAB-ANSWER-BAR" "BT-CAB-ANSWER-BAR-2" "BT-CAB-CELLBAR" "BT-CORE-GRAPHICS-22"                    "BT-COUNTER-CONSULT-96" "BT-COUNTER-POS-L-108" "BT-COUNTER-POS-R-108" "BT-EREADERS-TABLETS" "CC-AM-48" "CC-CAT105"                    "CC-CS10-SSC-CABINET" "CC-HPZ2100-24" "CC-HPZ2100-44" "CC-HSB" "CC-HSC" "CC-KM4850" "CC-LFB" "CC-LFC" "CC-MEDIA-360"))   (setq All_Block_Set (ssget "_X" '((0 . "INSERT") (8 . "fxpm,fxw,fxdt,ardt"))))   (setq NumBk (sslength All_Block_Set))   (setq Count 0)   (repeat NumBk      (setq Ename (ssname All_Block_Set Count))      (setq edata (entget Ename))      (setq BkName (cdr (assoc 2 edata)))      (if (member BkName block_list)          (progn              (setq newdata (subst (cons 8 NewLayer) (assoc 8 edata) edata))              (entmod newdata)           )       )      (setq Count (1+ Count))   ))(princ "\nType BS1 to start")(princ)[/code]

Kent Cooper
11.04.2013, 17:53
callvey wrote:
  ...

  How do I use this in a lisp I have this but it doesn't work?

  (defun BS1 ()
  (ssget "x" '((8 . "fxpm,fxw,fxdt,ardt")(2 .  "4plug, ...
  ....
  ... ,CC-MEDIA-360")))
 
 
I don't know for sure whether this is one of them, but I know there are situations in which there is a limit to the allowable length of a text string.  You might try some wildcards to shorten the Block list, for example, maybe replace this much:
BC-COUNTER-CONSULT-96,BC-COUNTER-CONSULT-96-L,BC-COUNTER-CONSULT-96-R,
 
with this:
 
BC-COUNTER-CONSULT-96*,
or if you want all Blocks with names starting with BT, you can replace 9 names in the list with BT*.  Etc., etc.