Author Topic: Changing numerous blocks (40 or so) to another layer at once  (Read 3518 times)

0 Members and 1 Guest are viewing this topic.

TJAM51

  • Guest
We receive drawings from out client. These blocks are on the same layer. There are approximately 40 or so blocks total. Now each block has to be on a separate layer for out company to use in our MEP drawings. I am seeking a method of selecting all these blocks (remember theyall have separate names and each one needs to be on it's own layer) and placing them on their own specific layers. This needs to be done in one step or one run of a routine. Routines like "Get" as described in other discussions on this forum do not work due to the operator picking each block name separately. Any suggestions or ideas...thanks

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Changing numerous blocks (40 or so) to another layer at once
« Reply #1 on: June 23, 2005, 10:19:15 AM »
what does the layer name have to be?  could the layername be the same as the block name?  if so, that would be very easy
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

TJAM51

  • Guest
Changing numerous blocks (40 or so) to another layer at once
« Reply #2 on: June 23, 2005, 10:31:02 AM »
The system seems to be kicking me out.......the layer names cannot match the block name. This is a decision made by higher ups. If someone could show me how to start the routine......show me next how to select the block and then place it on it's specified layer I could type in the rest.


Thanks

daron

  • Guest
Changing numerous blocks (40 or so) to another layer at once
« Reply #3 on: June 23, 2005, 10:53:11 AM »
(setq ss (ssget "x" '((0 . "INSERT"))))

that'll start you. If you want to name specific blocks use '((2 . "blocknamehere"))

TJAM51

  • Guest
Changing numerous blocks (40 or so) to another layer at once
« Reply #4 on: June 23, 2005, 12:35:33 PM »
If I wanted to change the actual block to another layer how would that be stated?

Jeff_M

  • King Gator
  • Posts: 4098
  • C3D user & customizer
Changing numerous blocks (40 or so) to another layer at once
« Reply #5 on: June 23, 2005, 01:30:59 PM »
This doesn't do the actual layer decision making, but it shows how you'd modify the block's layer.
Code: [Select]

(if (setq ss (ssget "x" '((0 . "INSERT"))))
  (progn
    (setq idx -1)
    (while (< (setq idx (1+ idx))(sslength ss))
      (setq ent (entget (ssname ss idx))
   bname (cdr (assoc 2 ent))
   ent (subst (cons 8 "whatever the layer should be here") (assoc 8 ent) ent)
   )
      (entmod ent)
      )
    )
  )

daron

  • Guest
Changing numerous blocks (40 or so) to another layer at once
« Reply #6 on: June 23, 2005, 02:23:54 PM »
Quote from: TJAM51
If I wanted to change the actual block to another layer how would that be stated?

Like that^. :lol: Good work Jeff.

TJAM51

  • Guest
Changing numerous blocks (40 or so) to another layer at once
« Reply #7 on: June 24, 2005, 11:38:22 AM »
ANOTHER APPROACH..........I have created a menu button with the following script...........

-LAYER;M;E-LITA;C;30;;;^C^CSSX;;BLOCK;TYPE_300;;^C^CCHANGE;PREVIOUS;;P;LA;E-LITA;;


This button only deals with converting one block to one layer. I need to include numerous more blocks for this layer. How can this be written to include 17 more blocks?

daron

  • Guest
Changing numerous blocks (40 or so) to another layer at once
« Reply #8 on: June 24, 2005, 11:46:46 AM »
Use Jeff's.
Change this line:
Code: [Select]
(if (setq ss (ssget "x" '((0 . "INSERT"))))
to
Code: [Select]
(if (setq ss (ssget "x" '(((-4 . "<OR") (2 . "blockname") (2 . "nextblockname_etc") (-4 . "OR>"))))

TJAM51

  • Guest
Changing numerous blocks (40 or so) to another layer at once
« Reply #9 on: June 24, 2005, 11:53:38 AM »
Ok...ltes see if I am heading in the right direction.....


(DEFUN C:GENERAL)
  (command "LAYER" "M" "E-LITG" "C" "30" "" ""
           "LAYER" "M" "E-LITA" "C" "30" "" "")
(if (setq ss (ssget "x" '(((-4 . "<OR") (2 . "TYPE_110")
(2 . "TYPE_122") (2. "type_120") (-4 . "OR>"))))
(PRINC)

I would continue to add the remaining block names as shown above, right? I receive the error messagen "SYNTAX ERROR".

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Changing numerous blocks (40 or so) to another layer at once
« Reply #10 on: June 24, 2005, 12:29:47 PM »
try this one;

Code: [Select]

(DEFUN C:GENERAL (/ ss)

  (command "LAYER" "M" "E-LITG" "C" "30" "" "")
  (command "LAYER" "M" "E-LITA" "C" "30" "" "")

  (if
    (setq ss
  (ssget "x"
 '(
   (-4 . "<OR")
   (2 . "TYPE_110")
   (2 . "TYPE_122")
   (2 . "type_120")
   (-4 . "OR>")
  )
  )
    )
     (princ (strcat "\nFound " (itoa (sslength ss)) " blocks"))
  )

  (PRINC)
)
TheSwamp.org  (serving the CAD community since 2003)

TJAM51

  • Guest
Changing numerous blocks (40 or so) to another layer at once
« Reply #11 on: June 24, 2005, 12:43:53 PM »
Here is the final routine for the layer E-LITG.....

(DEFUN C:litg (/ ss)
  (command "LAYER" "M" "E-LITG" "C" "30" "" "")
  (if
    (setq ss
      (ssget "x"
        '(
          (-4 . "<OR")
          (2 . "TYPE_110")
          (2 . "TYPE_122")
          (2 . "type_120")
          (2 . "TYPE_125")
          (2 . "TYPE_112")
          (2 . "type_130-4")
          (2 . "type_130-8")
          (2 . "type_131-4")
          (2 . "type_131-8")
          (2 . "type_163")
          (2 . "type_180-8")
          (2 . "type_184")
          (2 . "type_128")
          (2 . "type_366")
          (2 . "type_495")
          (2 . "type_393")
          (2 . "type_498")
          (2 . "type_498e")
          (-4 . "OR>")
         )
      )
    )
     (princ (strcat "\nFound " (itoa (sslength ss)) " blocks"))
  )

  (PRINC)
)


The only problem is that it will not affect any blocks from TYPE_120 on down. They remain on the same layer and color.....did I type something wrong?

Thanks

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Changing numerous blocks (40 or so) to another layer at once
« Reply #12 on: June 24, 2005, 12:58:20 PM »
What you have looks right but you're not doing anything to the blocks in the selection set (ss). Now you have to iterate through the selection set and modify the blocks.

BTW have you tried "Quick Select"

http://www.theswamp.org/screens/mark/screen_shots/quick_select_blkname.png
TheSwamp.org  (serving the CAD community since 2003)

TJAM51

  • Guest
Changing numerous blocks (40 or so) to another layer at once
« Reply #13 on: June 24, 2005, 01:01:27 PM »
Yes I have but attempting to eliminate as many steps as possible....

Jeff_M

  • King Gator
  • Posts: 4098
  • C3D user & customizer
Changing numerous blocks (40 or so) to another layer at once
« Reply #14 on: June 24, 2005, 01:20:07 PM »
Here's another way of doing the same thing:
Code: [Select]

(DEFUN C:litg (/ ss)
  (command "LAYER" "M" "E-LITG" "C" "30" "" "")
  (if
    (setq ss
  (ssget "x"
 '((2 . "TYPE_110,TYPE_122,type_120,TYPE_125,TYPE_112,type_130-4,type_130-8,type_131-4,type_131-8,type_163,type_180-8,type_184,type_128,type_366,type_495,type_393,type_498,type_498e"))
  )
    )
    (progn
     (princ (strcat "\nFound " (itoa (sslength ss)) " blocks"))
     (command ".chprop" ss "" "la" "E-LITG" "")
     )
  )

  (PRINC)
)

TJAM51

  • Guest
Changing numerous blocks (40 or so) to another layer at once
« Reply #15 on: June 24, 2005, 01:24:13 PM »
That is strange...this routine you added works great.....who can figure.....thanks

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Changing numerous blocks (40 or so) to another layer at once
« Reply #16 on: June 24, 2005, 01:36:54 PM »
Code: [Select]
(DEFUN C:GENERAL (/ ss)

  (command "LAYER" "M" "E-LITG" "C" "30" "" "")
  (command "LAYER" "M" "E-LITA" "C" "30" "" "")

  (if
    (setq ss
  (ssget "x"
 '(
   (-4 . "<OR")
   (2 . "TYPE_110")
   (2 . "TYPE_122")
   (2 . "type_120")
   (-4 . "OR>")
  )
  )
    )
     (progn
       (setq cntr 0)
       (while (setq ent (ssname ss cntr))

(setq entlst (entget ent))
(setq entlst
(subst
 (cons 8 "0") ; change layer name here
 (assoc 8 entlst)
 entlst
)
)
(entmod entlst)

(setq cntr (1+ cntr))
       )
     )
  )

  (PRINC)
)
TheSwamp.org  (serving the CAD community since 2003)