Author Topic: Automatically generated blocks with individual names  (Read 2972 times)

0 Members and 1 Guest are viewing this topic.

GISDUDE

  • Guest
Automatically generated blocks with individual names
« on: November 08, 2012, 11:27:08 AM »
Hi all,
I have a converted DGN file that has a 30 or so storm drains that are blocks - but with individual names that are numbered sequentially. I have "placed" them on a separate layer, but I can't isolate them by themselves, ie turn off the layer or isolate it.

Do I have to explode each one individually and re-do the blocks? There has to be a simpler way?

Sometimes microstation is the worst program to work with...

TIA,
Randy

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: Automatically generated blocks with individual names
« Reply #1 on: November 08, 2012, 12:10:20 PM »
Perhaps the following program will help:

Code - Auto/Visual Lisp: [Select]
  1. ;; All to Layer 0  -  Lee Mac
  2. ;; Places every object in a selection on Layer 0 (including nested objects)
  3.  
  4. (defun c:lay0 ( / _blocktolay0 _entitytolay0 e i l s x )
  5.  
  6.     (defun _blocktolay0 ( n / e x )
  7.         (if (and
  8.                 (not (member n l))
  9.                 (setq e (tblobjname "BLOCK" n))
  10.                 (setq l (cons n l))
  11.                 (zerop (logand 4 (cdr (assoc 70 (entget e)))))
  12.             )
  13.             (while (setq e (entnext e))
  14.                 (setq x (entget e)
  15.                       x (subst '(8 . "0") (assoc 8 x) x)
  16.                 )
  17.                 (entmod x)
  18.                 (if (= "INSERT" (cdr (assoc 0 x)))
  19.                     (_blocktolay0 (cdr (assoc 2 x)))
  20.                 )
  21.             )
  22.         )
  23.     )
  24.  
  25.     (defun _entitytolay0 ( e )
  26.         (entmod (subst '(8 . "0") (assoc 8 e) e))
  27.     )
  28.    
  29.     (if (setq s (ssget "_:L" '((0 . "~VIEWPORT"))))
  30.         (repeat (setq i (sslength s))
  31.             (setq e (ssname s (setq i (1- i)))
  32.                   x (entget e)
  33.             )
  34.             (_entitytolay0 x)
  35.             (if (= "INSERT" (cdr (assoc 0 x)))
  36.                 (_blocktolay0 (cdr (assoc 2 x)))
  37.             )
  38.             (if (= 1 (cdr (assoc 66 x)))
  39.                 (while (/= "SEQEND" (cdr (assoc 0 (entget (setq e (entnext e))))))
  40.                     (_entitytolay0 (entget e))
  41.                 )
  42.             )
  43.         )
  44.     )
  45.     (command "_.regen")
  46.     (princ)
  47. )

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Automatically generated blocks with individual names
« Reply #2 on: November 08, 2012, 01:35:36 PM »
If this is a layering issue, check out the SETBYLAYER command - no programming needed.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

GISDUDE

  • Guest
Re: Automatically generated blocks with individual names
« Reply #3 on: November 08, 2012, 04:07:23 PM »
I don't think I explained myself right. All of these blocks that were converted are ALL ON LAYER 0. I need to place all of the blocks on their own (better descriptive) layers (ie storm drains, monuments, communications, culverts, etc). This is why this is kinda frustrating, b/c if all of the blocks were named say "storm drain" for all the drains, "culverts" for all the culverts, this would be very easy by using a LISP function, but now it's made 10 times harder cause they are ALL uniquely named.

Thanks,

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Automatically generated blocks with individual names
« Reply #4 on: November 08, 2012, 04:13:47 PM »
<Short response which is all I've time for>

Block defs or instances?

Defs defined on layer 0 good.

Instances existing on layer 0 bad.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Automatically generated blocks with individual names
« Reply #5 on: November 08, 2012, 04:56:08 PM »
Let me take a guess.  8-)

Inserts are named "Storm-1" "Storm-2" "Storm-3"  etc.
when the name should be "Storm Drain" for all the insets.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

GISDUDE

  • Guest
Re: Automatically generated blocks with individual names
« Reply #6 on: November 08, 2012, 05:07:03 PM »
Let me take a guess.  8-)

Inserts are named "Storm-1" "Storm-2" "Storm-3"  etc.
when the name should be "Storm Drain" for all the insets.
yeah, basically whoever (surveyor/cad tech) created the points for the drains/culverts/whatever they had the program (could be trimble?) generate a 1000 unique blocks. sux.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Automatically generated blocks with individual names
« Reply #7 on: November 08, 2012, 05:33:54 PM »
You can easily grab all those blocks with the built in FILTER command like so:

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: Automatically generated blocks with individual names
« Reply #8 on: November 08, 2012, 06:11:01 PM »
Block defs or instances?

Defs defined on layer 0 good.

Instances existing on layer 0 bad.

1+


CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Automatically generated blocks with individual names
« Reply #9 on: November 08, 2012, 09:10:32 PM »
So, all you need to do is replace inserts selected with one block of your choice?
http://www.theswamp.org/index.php?topic=29821.msg353978#msg353978
There are many other routines if that one doesn't do the job.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Crank

  • Water Moccasin
  • Posts: 1503
Re: Automatically generated blocks with individual names
« Reply #10 on: November 11, 2012, 12:37:30 PM »
The RENAME-dialog also accepts wildcards.
Vault Professional 2023     +     AEC Collection

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Automatically generated blocks with individual names
« Reply #11 on: November 11, 2012, 01:24:23 PM »
Interesting, but with existing blocks with inserts would that be a replace for the existing inserts?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.