Author Topic: Apply layer properties directly to objects  (Read 1843 times)

0 Members and 1 Guest are viewing this topic.

diarmuid

  • Bull Frog
  • Posts: 417
Apply layer properties directly to objects
« on: November 23, 2012, 08:58:02 AM »
ok, this is going to sound daft. but here me out.  i am under a contractual obligation to provide a set of CAD files in a particualr client CAD standard.  Which is over 25 years old and is older than half of the CAD users working for me at the moment.  This standard uses 9 layers, for every thing.  yes 9. not 90, but 9 and 9 only.

I have set of services drawings that, accirding to this Fu_ked up standard can only go on 3 layers.  i have over 40 different types of servcies across about 20 drawings.  So, i will have to merge them down to 3 layers. (we were not allowed to use xrefs on this project, stoneage stuff i know)

is there a way that i can take an individual layers properties, and apply them directly to the lines contained on that layer?

So layer "foul_drain" has all lines etc as bylayer.  The layer itself has a dashdot linetype and color cyan.  can i quickly apply the layer settings directyl to the entities.  so that when i merge them i at least retain the color and linetype format.

Your help would be greatly appreciated in this.

Regards

Diarmuid
If you want to win something run the 100m, if you want to experience something run a marathon

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Apply layer properties directly to objects
« Reply #1 on: November 23, 2012, 09:11:05 AM »
Very quickly written & untested:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:maplayprop ( / ass def ent inc lay lst prp sel )
  2.     (if (setq sel (ssget "_:L"))
  3.         (repeat (setq inc (sslength sel))
  4.             (setq ent (entget (ssname sel (setq inc (1- inc))))
  5.                   lay (cdr (assoc 8 ent))
  6.             )
  7.             (if (setq prp (cdr (assoc lay lst)))
  8.                 (_substpairs prp ent)
  9.                 (progn
  10.                     (setq def (entget (tblobjname "LAYER" lay))
  11.                           prp nil
  12.                     )
  13.                     (foreach dxf '(6 62 370)
  14.                         (if (setq ass (assoc dxf def))
  15.                             (setq prp (cons ass prp))
  16.                         )
  17.                     )
  18.                     (setq lst (cons (cons lay prp) lst))
  19.                     (_substpairs prp ent)
  20.                 )
  21.             )
  22.         )
  23.     )
  24.     (princ)
  25. )
  26.  
  27. (defun _substpairs ( pairs elst / item )
  28.     (foreach pair pairs
  29.         (if (setq item (assoc (car pair) elst))
  30.             (setq elst (subst pair item elst))
  31.             (setq elst (append elst (list pair)))
  32.         )
  33.     )
  34.     (entmod elst)
  35. )

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

diarmuid

  • Bull Frog
  • Posts: 417
Re: Apply layer properties directly to objects
« Reply #3 on: November 28, 2012, 04:57:24 AM »
Perfect, that is exactly what i need.  Thanks a mil guys!

Regards

Diarmuid
If you want to win something run the 100m, if you want to experience something run a marathon

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Apply layer properties directly to objects
« Reply #4 on: November 28, 2012, 07:14:59 AM »
You're welcome Diarmuid  :-)