LAYMRG by Layer COLOR

LAYMRG by Layer COLOR

4co2op0
Contributor Contributor
5,144 Views
25 Replies
Message 1 of 26

LAYMRG by Layer COLOR

4co2op0
Contributor
Contributor

Hello All,

 

I have a base file from the CIVIL and I must convert all of the CIVIL's layers to different layer names/colors to meet another companies layer standards. All of the CIVIL layers have been assigned colors that are typical for all of drawing plot settings

 

Example: Civil file has layers such as Curb (color 150), Curb-back (color 150), Curb-face (color 150), Curb-Gutter (color 8), Curb-Drain (color 113)...

 

I need to merge all the "color 150" layers to a generic "CURB" layer, the "color 8" layers need to change to a generic "GUTTER" layer, and the "color 113" layers need to change to a generic "DRAIN" layer.

 

When using the LAYERMANAGER I can sort by color and select all "color 150" layers, right click and merge the layers to the new desired layer name. Then select all "color 8" layers and merge to the desired layer, then select all "color 113" layers and merge to that desired layer. This process does work very well, but when doing this to 100's of drawing files it is very redundant and time consuming. 

 

If it is possible to setup a LISP routine that will automate this process by changing all desired layers that are on a specific COLOR to a different specified layer it would save me hours of time per week and make the learning curve for new drafters quite a bit easier.

 

I have tried the LAYTRANS command and it almost works except for the layer name problems such as *CURB* would also select the "CURB-DRAIN" layer and "CURB-GUTTER" layer which will not work for my use.

 

Any suggestions are greatly appreciated. TYIA

 

NOTE: I am not very good at creating LISP routines. I have adjusted pre-made LISP routines to fit my needs in the past and also created VERY VERY Basic LISP routines as well but this is beyond my ability. I also read that the LAYMRG command doesnt quite work right in LISP routines but I am hoping someone can point me in the right direction for a solution to my "desires"

 

-Matt

 

 

0 Likes
Accepted solutions (2)
5,145 Views
25 Replies
Replies (25)
Message 21 of 26

DannyNL
Advisor
Advisor
Hi Matt,

 

          (113 "WATER" ("*WTR" "*WAT" "*FIRE" "*RECLAIMED")

does it completely ignore all other items on color 113 that do not fit into the wildcard search?


 

Yes, it does. With this line of code only layers with color 113 and matching one of the provided wildcards will be processed. All others will be ignored.

However, if you omit a wildcard like in (113 "DRAIN") it will be catch-all filter. So all layers matching color 113 will be merged onto layer DRAIN. So like in the example you can create multiple filters for the same color in the list.

 

      1)    (113 "FH"    ("*FH"))
      2)    (113 "WATER" ("*WTR" "*WAT" "*FIRE" "*RECLAIMED"))
      3)    (113 "DRAIN")

 

  1. If a layer has color 113 and the name ends with FH, the layer will be merged onto layer FH
  2. If one of the remaining layers has color 113 and ends with WTR, WAT, FIRE or RECLAIMED, the layer will be merged onto layer WATER
  3. All other remaining layers with color 113 will be merged onto layer DRAIN

 

Regarding the changing of the color of the target layer, yes you are right. It is something I have changed as I thought it was an error in my code. This is controlled by the code below. It will check if the target layer exists. If not it will be created with the same color as defined in the filter.

And if the target layer does exist, the color will changed to the defined color in the filter.

 

If you do not want the color to be changed of an existing target layer, just remove or comment the marked line in the code below.

 

 

...
...
(if (not (tblsearch "LAYER" (nth 1 T_Item))) (command "-LAYER" "N" (nth 1 T_Item) "C" (nth 0 T_Item) (nth 1 T_Item) "") (command "-LAYER" "C" (nth 0 T_Item) (nth 1 T_Item) "") ; <-- Remove or comment with ; )
...
...

 

Message 22 of 26

4co2op0
Contributor
Contributor

Thanks again Danny. Removing that line did exactly what I needed.

I have a layer state saved with all the layers that I am changing to, and they are all set to load with "LAYOFF", so once the Laymrg Lisp you created runs, the only items left visible (LayOn) are ones not included in my list and I can then check them one by one to make sure they go on the generic layer for the "leftovers" (or if they are items that can be added to the list).

 

This has made my life so easy already.

 

Thank you so much.

 

Not that I think it will benefit anyone much but below is the list I have created and it works so unbelievably well! I will have to add to it and adjust it over time but what an awesome Lisp routine you have created.

 

          (1   "CL"        ("*CEN*" "*CL*" "*CNTR*" "*CTLN*"))
          (1   "EP"        ("*ASPH*" "*EP*" "*EOP*" "*PAV*" "*BERM*" "*EDGE*" "*SHOULDER*" "*SHLD*"))
          (2   "PL"        ("*PL*" "*LOT*" "*PROP*" "*TR*" "*PAR*"))
          (2   "ST-LT"     ("*LT*" "*LIGHT*" "*SL*" "*LITE*" "*STL*"))
          (4   "DWY"       ("*DWY*" "*WAY*" "*DRIVE*"))
          (4   "SW"        ("*SW*" "*WALK*" "*SIDE*" "*WLK*" "*BW*"))
          (4   "WALK"      ("*CONC*" "*EC*" "*PLANTER*" "*PAD*" "*POOL*" "*HARD*" "*SCAPE*" "*FS*" "*BRIDGE*"  "*CHAN*"))
          (7   "ELECTRIC"  ("*ELEC*" "*POW*" "*PWR*" "*PAD*" "*TRANS*" "*VAULT*" "*VLT*" "*GUY*"))
          (7   "TEL"       ("*TEL*" "*PHO*" "*T"))
          (7   "CATV"      ("*TV*" "*CABLE*" "*CBL*"))
          (7   "GAS"       ("*GAS*" "*G" "*FUEL*"))
          (7   "OIL"       ("*OIL*"))
          (7   "RR"        ("*RAIL*" "*RR*" "*TRACK*"))
          (7   "MISC"      ("*BOLL*" "*BLD*" "*POST*" "*MISC*"))
          (8   "GUTTER")
          (9   "FENCE")
          (30  "ELECTRIC")
          (50  "RW"        ("*RW*" "*ROW*" "*WAY*"))
          (103 "LANDSCAPE")
          (113 "FH"        ("*FH*" "*HYD*"))
          (113 "CB"        ("*CB*" "*CATCH*"))
          (113 "WATER"     ("*FIRE*" "*WTR*" "*WAT*" "*RECLAIM*" "*RW*" "*RECY*" "*WV*" "*FV*" "*WMET*" "*THRUST*" "*WM*" "*TB*" "*IRR*" "*FW*" "*VALVE*" "*ICV*" "*FRMN*" ))
          (113 "SD"        ("*SD*" "*DRAIN*" "*STRM*" "*STORM*" "*BIO*" "*RD*" "*OUTLET*" "*INLET*" "*CHAMBER*" "*CULV*" "*CANAL*" "*RIP*" "*GRATE*"))
          (113 "SEWER"     ("*SEW*" "*SWR*" "*SANI*" "*CLEANOUT*" "*SW*" "*SS*"))
          (150 "CURB")
          (153 "WALL")
          (213 "BUILD")
          (233 "BOUNDARY")
          (252 "TOPO"      ("*SIGN*" "*RAIL*" "*HAND*"))
          (253 "CURB"      ("*CURB*" "*BC*" "*BOC*" "*BK*" "*CRB*"))
          (253 "TOPO"      ("*STRP*" "*STRIP*" "*PAINT*" "*PARK*" "*PRK*" "*FL*" "*FLOW*" "*SS*" "*TOE*" "*TOP*" "*SLOPE*" "*PNT*" "*GB*" "*DAY*"))
          (253 "HATCH"     ("*HATCH*" "*PATT*"))
          (254 "TOPO"      ("*GB*" "*DAY*" "*TOE*" "*TOP*" "*SLOPE*" "*CONT*" "*MAJ*" "*MJR*" "*MIN*" "*MNR*" "*IND*" "*INT*" "*GRID*" "*DOME*" "*SWALE*" "*ARROW*" "*DAY*" "*GRAD*" "*HATCH*"))
          (255 "EASEMENT"  ("*ESMT*" "*EASE*" "*SETBACK*"))
          (255 "OH-EX"     ("*OVR*" "*OH*" "*OVER*"))
          (255 "ELECTRIC"  ("*E" "*ELEC*" "*POW*" "*PWR*" "*PAD*" "*TRANS*" "*VAULT*" "*VLT*" "*GUY*"))
          (255 "TEL"       ("*TEL*" "*PHO*" "*T"))
          (255 "CATV"      ("*TV*" "*CABLE*" "*CBL*"))
          (255 "GAS"       ("*GAS*" "*G" "*FUEL*"))
          (255 "OIL"       ("*OIL*"))
          (255 "TS"        ("*TS*" "*TRAF*" "*SIG*"))
          (255 "RR"        ("*RAIL*" "*RR*" "*TRACK*"))
          (255 "MISC"      ("*BOLL*" "*BLD*" "*POST*" "*UT*" "*METER*" "*OPTIC*" "*MISC*" "*PAD*" "*PB*" "*COND*"))

 

 

0 Likes
Message 23 of 26

john.uhden
Mentor
Mentor

You did good!.

Just one thing... you have to put a single quote before the list of wildcard layer names, as in...

(113 "FH"        '("*FH*" "*HYD*"))
here ---^

 This is true for each item in the overall list.

John F. Uhden

0 Likes
Message 24 of 26

DannyNL
Advisor
Advisor

@4co2op0: You're welcome Matt and glad I could help Smiley Happy

 

 

@john.uhden: you are right if this is the only part of the code.

However, the quote has already been provided at one level higher, where the total layer list is constructed. So Matt's code will look something like this.

 

 

...
...
   (setq T_LayMatrix
      '(
^ (1 "CL" ("*CEN*" "*CL*" "*CNTR*" "*CTLN*"))
here -|   (1 "EP" ("*ASPH*" "*EP*" "*EOP*" "*PAV*" "*BERM*" "*EDGE*" "*SHOULDER*" "*SHLD*"))
          (2 "PL" ("*PL*" "*LOT*" "*PROP*" "*TR*" "*PAR*"))
          (2 "ST-LT" ("*LT*" "*LIGHT*" "*SL*" "*LITE*" "*STL*"))
          (4 "DWY" ("*DWY*" "*WAY*" "*DRIVE*"))
          (4 "SW" ("*SW*" "*WALK*" "*SIDE*" "*WLK*" "*BW*"))
          (4 "WALK" ("*CONC*" "*EC*" "*PLANTER*" "*PAD*" "*POOL*" "*HARD*" "*SCAPE*" "*FS*" "*BRIDGE*" "*CHAN*"))
          (7 "ELECTRIC" ("*ELEC*" "*POW*" "*PWR*" "*PAD*" "*TRANS*" "*VAULT*" "*VLT*" "*GUY*"))
...
...

 

0 Likes
Message 25 of 26

4co2op0
Contributor
Contributor
I guess I should have just copied the entire code instead of just that portion. Sorry. Everything seems to be working perfectly at this point and I couldn't be happier.
0 Likes
Message 26 of 26

john.uhden
Mentor
Mentor

My apologies for misquoting.  🙂

 

YAY!  We love to hear good news!

John F. Uhden

0 Likes