CAD Forum - Database of tips, tricks and utilities for AutoCAD, Inventor and other Autodesk products [www.cadforum.cz]
CZ | EN | DE
Login or
registration
  Visitors: 1594
RSS channel - CAD tips RSS tips
RSS discussions

Discussion Discussion forum

 

HelpCAD discussion

 
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.

How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic ClosedSelect list of blocks from specific layers

 Post Reply Post Reply Page  <12
Author
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
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
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
Kent Cooper View Drop Down
Senior Member
Senior Member


Joined: 12.Mar.2013
Location: United States
Using: AutoCAD2020, 2023
Status: Offline
Points: 632
Direct Link To This Post 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

Related CAD tips:


 Post Reply Post Reply Page  <12
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0,320 seconds.