CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz] ARKANCE | CONTACT - CZ | SK | EN | DE
Over 1.095.000 registered users (EN+CZ). AutoCAD tips, Inventor tips, Revit tips. Try the new precise Engineering calculator. New AutoCAD 2026 commands and variables.
RSS channel - CAD tips RSS tips
RSS discussions

Discussion Discussion forum

?
CAD discussions, advices, exchange of experience

CAD Forum - Homepage CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate forum.

Please abide by the rules of this forum.
This is a peer-to-peer forum. The forum doesn't replace the official direct technical support provided by ARKANCE for its customers.
How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
  FAQ FAQ  Forum Search Search  Events Events  Register Register  Login Login

Topic ClosedSelect list of blocks from specific layers

 Post Reply Post Reply Page  12>
Author
Kent Cooper View Drop Down
Senior Member
Senior Member


Joined: 12.Mar.2013
Location: United States
Using: AutoCAD2020, 2023
Status: Offline
Points: 685
Direct Link To This Post Topic: Select list of blocks from specific layers
    Posted: 11.Apr.2013 at 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.
Back to Top
CarlB View Drop Down
Senior Member
Senior Member


Joined: 16.Oct.2009
Location: United States
Status: Offline
Points: 321
Direct Link To This Post Posted: 10.Apr.2013 at 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.
 
(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)
Back to Top
CarlB View Drop Down
Senior Member
Senior Member


Joined: 16.Oct.2009
Location: United States
Status: Offline
Points: 321
Direct Link To This Post Posted: 09.Apr.2013 at 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.
Back to Top
callvey View Drop Down
Newbie
Newbie


Joined: 04.Apr.2013
Location: United Kingdom
Using: AutoCAD Architecture 2012
Status: Offline
Points: 6
Direct Link To This Post Posted: 09.Apr.2013 at 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.
Back to Top
callvey View Drop Down
Newbie
Newbie


Joined: 04.Apr.2013
Location: United Kingdom
Using: AutoCAD Architecture 2012
Status: Offline
Points: 6
Direct Link To This Post Posted: 09.Apr.2013 at 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")))


Back to Top
Kent Cooper View Drop Down
Senior Member
Senior Member


Joined: 12.Mar.2013
Location: United States
Using: AutoCAD2020, 2023
Status: Offline
Points: 685
Direct Link To This Post Posted: 05.Apr.2013 at 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).
Back to Top
CarlB View Drop Down
Senior Member
Senior Member


Joined: 16.Oct.2009
Location: United States
Status: Offline
Points: 321
Direct Link To This Post Posted: 05.Apr.2013 at 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?
Back to Top
heinsite View Drop Down
Senior Member
Senior Member


Joined: 05.Feb.2009
Location: United States
Using: AutoCAD 2014
Status: Offline
Points: 640
Direct Link To This Post Posted: 05.Apr.2013 at 12:23
And QSELECT didn't work for you either?

Dave.
Dave Hein, P.E.
Hawaii District Engineer
Kona International Airport
AutoCAD Certified Professional
Autodesk Expert Elite
Back to Top
callvey View Drop Down
Newbie
Newbie


Joined: 04.Apr.2013
Location: United Kingdom
Using: AutoCAD Architecture 2012
Status: Offline
Points: 6
Direct Link To This Post Posted: 05.Apr.2013 at 11:44
Do you know of an example script that i can analyse please.

Thanks
 
Back to Top
John Connor View Drop Down
Senior Member
Senior Member


Joined: 01.Feb.2011
Location: United States
Using: AutoCAD 2018
Status: Offline
Points: 7175
Direct Link To This Post Posted: 05.Apr.2013 at 11:40
It sounds more like you need a custom lisp routine not a macro.
"Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."

<<AutoCAD 2015>>

Back to Top

Related CAD tips:


 Post Reply Post Reply Page  12>
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0,129 seconds.