Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Layer translator lisp

79 REPLIES 79
SOLVED
Reply
Message 1 of 80
brettgr
3938 Views, 79 Replies

Layer translator lisp

I found a lisp in an old post and I edited it alittle with my own layers to have it change to but when I use it, it doesn't deleted the extra layers. It says layer cannot be deleted. Below is part of the code that I am using, I didn't copy all of them since there are alot of layers in the lisp that I added. Any help would be great. maybe I copied something wrong I am not sure.

 

 

{code}
( defun c:FIXMYLAYERS ( / ss_newlayer change_en )
( setq layerlist ( list ( cons "ENB_ROW-1" "ENB-ROW-1" )
( cons "Border_Condoc_DwgMgmt_Large$0$G-ANNO-TTLB" "DefPoints" )
( cons "Border_Condoc_DwgMgmt_Large$0$G-ANNO-TTLB-LOGO" "DefPoints" )
( cons "Border_Condoc_DwgMgmt_Large$0$G-ANNO-TTLB-NPLT" "DefPoints" )
( cons "Border_Condoc_DwgMgmt_Large$0$G-ANNO-TTLB-TEXT" "DefPoints" )
( cons "Border_Condoc_DwgMgmt_Small$0$G-ANNO-TTLB-LOGO" "DefPoints" )
( cons "Border_Condoc_DwgMgmt_Small$0$G-ANNO-TTLB-NPLT" "DefPoints" )
( cons "Border_Condoc_DwgMgmt_Small$0$G-ANNO-TTLB-TEXT" "DefPoints" )
( cons "DEFPPOINTS" "DefPoints" )
( cons "E-ANNO-REVC-0001" "AE NOTES" )
( cons "E-ANNO-REVC-0002" "AE NOTES" )
( cons "E-ANNO-REVS-0001" "AE NOTES" )
( cons "E-ANNO-REVS-0002" "AE NOTES" )
( cons "E-CLNG" "CEILING" )
( cons "ED-FIRE-CLNG" "AE FIRE ALARM" )
( cons "ED-LITE-SWCH" "AE ELECTRICAL" )
( cons "E-DP-2D$0$AD-BLDG" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-AREA-IDEN" "ROOM TAG" )
( cons "E-DP-2D$0$AE-AREA-OCCP" "ROOM TAG" )
( cons "E-DP-2D$0$AE-DOOR" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-EQPM" "EQUIPMENT" )
( cons "E-DP-2D$0$AE-EQPM-OVHD" "EQUIPMENT" )
( cons "E-DP-2D$0$AE-EQPM-UNDR" "EQUIPMENT" )
( cons "E-DP-2D$0$AE-FLOR" "MISC" )
( cons "E-DP-2D$0$AE-FLOR-CASE" "FURNITURE" )
( cons "E-DP-2D$0$AE-FLOR-CASE-OVHD" "FURNITURE" )
( cons "E-DP-2D$0$AE-FLOR-CASE-UNDR" "FURNITURE" )
( cons "E-DP-2D$0$AE-FLOR-EVTR" "MISC" )
( cons "E-DP-2D$0$AE-FLOR-OVHD" "MISC" )
( cons "E-DP-2D$0$AE-FLOR-SPCL" "MISC" )
( cons "E-DP-2D$0$AE-FLOR-STRS" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-FLOR-STRS-HRAL" "FLOORPLAN" )

( cons "E-DP-2D$0$AE-AREA-IDEN" "ROOM TAG" )
( cons "AE FIRE ALARM" "AE FIRE ALARM" )

( cons "TOPO-FENCE-200" "FENCE-200" )
( cons "HATCH-250" "HTCH-250" ) );list
);sq
( foreach item layerlist
( if ( and ( tblsearch "Layer" ( car item ) )
( not ( tblsearch "Layer" ( cdr item ) )) );a
( command "-Layer" "Rename" ( car item ) ( cdr item ) "" )
);i
);fe

( setq ss_newlayer ( ssget "X" ))
( while ( setq change_en ( ssname ss_newlayer 0 ))
( setq ss_newlayer ( ssdel change_en ss_newlayer ))
( if ( assoc ( cdr ( assoc 8 ( entget change_en ))) layerlist )
( entmod ( subst ( cons 8 ( cdr ( assoc ( cdr ( assoc 8 ( entget change_en ))) layerlist ))) ( assoc 8 ( entget change_en )) ( entget change_en ) ))
);i
);w

( foreach item layerlist
( if ( tblsearch "Layer" ( car item ) )
( command "-Layer" "Delete" ( car item ) "" )
);i
);fe
( princ "\nFinished:" )(princ ))
{code}

79 REPLIES 79
Message 2 of 80
dmfrazier
in reply to: brettgr

"...when I use it, it doesn't deleted the extra layers. It says layer cannot be deleted."

 

It seems to me there are two possibilities:

1. The layer is current at the time the routine tries to "delete" it.  (Not sure if this is true - some of the code I'm not sure about.)

2. The layer is in use (perhaps by block defs in the DWG).

 

Can(Have) you rule(d) these out?

Message 3 of 80
brettgr
in reply to: dmfrazier

My current layer is layer 0. So I don't think that is the issue, if I remember it right I don't have layer 0 being translated to anything. For the layer that might be used as a block or in a block is there a way the lisp can still change it with out exploding all blocks? For what Command Prompt says see below. It shows that it can not delete E-POWER-EQPM, but when I search for E-POWR-EQPM I can not find the layer using quick select by layer name and I also can't purge the layer out out of the drawing either. So not sure where the layer is being used I'm guessing it is being used in a block.

 

 

What command prompt shows after I run the command is:

-Layer
Current layer: "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: Delete
Enter layer(s) to delete: G-ANNO-TTLB The selected layers could not be deleted.
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]:
Command: -Layer
Current layer: "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: Delete
Enter layer(s) to delete: E-POWR-EQPM The selected layers could not be deleted.
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]:
Command:
Finished:

Message 4 of 80
Ajilal.Vijayan
in reply to: brettgr

( cons "E-DP-2D$0$AE-FLOR-STRS-HRAL" "FLOORPLAN" )

( cons "E-DP-2D$0$AE-AREA-IDEN" "ROOM TAG" )
( cons "AE FIRE ALARM" "AE FIRE ALARM" )

( cons "TOPO-FENCE-200" "FENCE-200" )
( cons "HATCH-250" "HTCH-250" ) );list
);sq
( foreach item layerlist


Dont know whether this is the problem.

 

Can you try your routine by changing the above highlighed line

( cons "AE FIRE ALARM" "AE FIRE ALARM" )

 

It seems the old layer name and new name looks same.

 

Message 5 of 80
pendean
in reply to: brettgr

Also, LAYDEL command may be invoked if you truly need to delete a layer and not worry if it has any content in it.
Message 6 of 80
brettgr
in reply to: Ajilal.Vijayan

I deleted the highlighted item and still come back can't delete the same layer but when I delete the layer out of the drawing and run it, it comes up with another layer which is called G-ANNO-TTLB and when I delete that layer out of the drawing all I get for a message is:

 

Command:

FIXMYLAYERS
Finished:

 

So I will copy over the whole lisp program to see if you can see anthing else that could be wrong else where, I dont see why its having any issues. I really hope I get this thing to work it will save so much time converting drawings.

 

 

{code}
( defun c:FIXMYLAYERS ( / ss_newlayer change_en )
( setq layerlist ( list ( cons "ENB_ROW-1" "ENB-ROW-1" )
( cons "Border_Condoc_DwgMgmt_Large$0$G-ANNO-TTLB" "DefPoints" )
( cons "Border_Condoc_DwgMgmt_Large$0$G-ANNO-TTLB-LOGO" "DefPoints" )
( cons "Border_Condoc_DwgMgmt_Large$0$G-ANNO-TTLB-NPLT" "DefPoints" )
( cons "Border_Condoc_DwgMgmt_Large$0$G-ANNO-TTLB-TEXT" "DefPoints" )
( cons "Border_Condoc_DwgMgmt_Small$0$G-ANNO-TTLB-LOGO" "DefPoints" )
( cons "Border_Condoc_DwgMgmt_Small$0$G-ANNO-TTLB-NPLT" "DefPoints" )
( cons "Border_Condoc_DwgMgmt_Small$0$G-ANNO-TTLB-TEXT" "DefPoints" )
( cons "DEFPPOINTS" "DefPoints" )
( cons "E-ANNO-REVC-0001" "AE NOTES" )
( cons "E-ANNO-REVC-0002" "AE NOTES" )
( cons "E-ANNO-REVS-0001" "AE NOTES" )
( cons "E-ANNO-REVS-0002" "AE NOTES" )
( cons "E-CLNG" "CEILING" )
( cons "ED-FIRE-CLNG" "AE FIRE ALARM" )
( cons "ED-LITE-SWCH" "AE ELECTRICAL" )
( cons "E-DP-2D$0$AD-BLDG" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-AREA-IDEN" "ROOM TAG" )
( cons "E-DP-2D$0$AE-AREA-OCCP" "ROOM TAG" )
( cons "E-DP-2D$0$AE-DOOR" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-EQPM" "EQUIPMENT" )
( cons "E-DP-2D$0$AE-EQPM-OVHD" "EQUIPMENT" )
( cons "E-DP-2D$0$AE-EQPM-UNDR" "EQUIPMENT" )
( cons "E-DP-2D$0$AE-FLOR" "MISC" )
( cons "E-DP-2D$0$AE-FLOR-CASE" "FURNITURE" )
( cons "E-DP-2D$0$AE-FLOR-CASE-OVHD" "FURNITURE" )
( cons "E-DP-2D$0$AE-FLOR-CASE-UNDR" "FURNITURE" )
( cons "E-DP-2D$0$AE-FLOR-EVTR" "MISC" )
( cons "E-DP-2D$0$AE-FLOR-OVHD" "MISC" )
( cons "E-DP-2D$0$AE-FLOR-SPCL" "MISC" )
( cons "E-DP-2D$0$AE-FLOR-STRS" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-FLOR-STRS-HRAL" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-FLOR-TPTN" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-GLAZ" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-WALL" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-WALL-CAVI" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-WALL-JAMB" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-WALL-SILL" "FLOORPLAN" )
( cons "E-DP-2D$0$EE-POWR-EQPM" "MISC" )
( cons "E-DP-2D$0$FE-EQPM" "MISC" )
( cons "E-DP-2D$0$G-ANNO-MATC" "GRID LINES" )
( cons "E-DP-2D$0$IE-FURN" "FURNITURE" )
( cons "E-DP-2D$0$AE-EQPM-OVHD" "EQUIPMENT" )
( cons "E-DP-2D$0$AE-EQPM-UNDR" "EQUIPMENT" )
( cons "E-DP-2D$0$AE-FLOR" "MISC" )
( cons "E-DP-2D$0$AE-FLOR-CASE" "FURNITURE" )
( cons "E-DP-2D$0$AE-FLOR-CASE-OVHD" "FURNITURE" )
( cons "E-DP-2D$0$AE-FLOR-CASE-UNDR" "FURNITURE" )
( cons "E-DP-2D$0$AE-FLOR-EVTR" "MISC" )
( cons "E-DP-2D$0$AE-FLOR-OVHD" "MISC" )
( cons "E-DP-2D$0$AE-FLOR-SPCL" "MISC" )
( cons "E-DP-2D$0$AE-FLOR-STRS" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-FLOR-STRS-HRAL" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-FLOR-TPTN" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-GLAZ" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-WALL" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-WALL-CAVI" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-WALL-JAMB" "FLOORPLAN" )
( cons "E-DP-2D$0$AE-WALL-SILL" "FLOORPLAN" )
( cons "E-DP-2D$0$EE-POWR-EQPM" "MISC" )
( cons "E-DP-2D$0$FE-EQPM" "MISC" )
( cons "E-DP-2D$0$G-ANNO-MATC" "GRID LINES" )
( cons "E-DP-2D$0$IE-FURN" "FURNITURE" )
( cons "E-FP-2D$0$A-FLOR-TPTN" "FLOORPLAN" )
( cons "E-FP-2D$0$A-FLOR-SPCL" "FURNITURE" )
( cons "E-FP-2D$0$A-FLOR-OVHD" "FURNITURE" )
( cons "E-FP-2D$0$A-WALL-SILL" "FLOORPLAN" )
( cons "E-FP-2D$0$A-FLOR" "MISC" )
( cons "G-ANNO-TTLB-NPLT" "DefPoints" )
( cons "G-ANNO-TTLB-LOGO" "DefPoints" )
( cons "G-ANNO-TTLB-STMP" "DefPoints" )
( cons "G-ANNO-TTLB-TEXT" "DefPoints" )
( cons "G-ANNO-TTLB" "DefPoints" )
( cons "E-POWR-ANNO" "AE ELECTRICAL" )
( cons "E-FIRE-CLNG" "AE FIRE ALARM" )
( cons "E-FIRE-WALL" "AE FIRE ALARM" )
( cons "E-LITE" "AE ELECTRICAL" )
( cons "E-LITE-ANNO" "AE ELECTRICAL" )
( cons "E-LITE-CIRC" "AE ELECTRICAL" )
( cons "E-LITE-CLNG" "AE ELECTRICAL" )
( cons "E-LITE-SWCH" "AE ELECTRICAL" )
( cons "E-LITE-WALL" "AE ELECTRICAL" )
( cons "E-POWR-EQPM" "AE ELECTRICAL" )
( cons "E-POWR-DEVC" "AE ELECTRICAL" )
( cons "E-LITE-CIRC-EMER" "AE ELECTRICAL" )
( cons "E-POWR-CIRC-EMER" "AE ELECTRICAL" )
( cons "ED-POWR-ANNO" "AE ELECTRICAL" )
( cons "ED-POWR-EQPM" "AE ELECTRICAL" )
( cons "EE-FIRE-CLNG" "AE FIRE ALARM" )
( cons "EE-FIRE-WALL" "AE FIRE ALARM" )
( cons "EE-LITE-ANNO" "DefPoints" )
( cons "EE-LITE-CLNG" "CEILING" )
( cons "EE-LITE-SWCH" "AE ELECTRICAL" )
( cons "EE-POWR-DEVC" "AE ELECTRICAL" )
( cons "EE-POWR-EQPM" "AE ELECTRICAL" )
( cons "EE-SERT" "AE ELECTRICAL" )
( cons "T-CATV" "AE ELECTRICAL" )
( cons "T-DATA" "AE ELECTRICAL" )
( cons "T-SOUN-CLNG" "AE ELECTRICAL" )
( cons "TD-PHON" "AE ELECTRICAL" )
( cons "TD-SOUN-CLNG" "DefPoints" )
( cons "TE-CATV" "AE ELECTRICAL" )
( cons "TE-DATA" "AE ELECTRICAL" )
( cons "TE-SOUN-CIRC" "AE ELECTRICAL" )
( cons "E-FP-2D$0$A-WALL-CAVI" "FLOORPLAN" )
( cons "E-FP-2D$0$A-EQPM-OVHD" "EQUIPMENT" )
( cons "E-FP-2D$0$E-POWR-EQPM" "AE ELECTRICAL" )
( cons "E-FP-2D$0$Q-EQPM" "EQUIPMENT" )
( cons "E-FP-2D$0$Q-EQPM-UNDR" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$AE-FLOR-STRS" "FLOORPLAN" )
( cons "GE-FLOR-E02B$0$AE-WALL" "FLOORPLAN" )
( cons "GE-FLOR-E02B$0$AE-FLOR-OVHD" "DefPoints" )
( cons "GE-FLOR-E02B$0$AE-WALL-CAVI" "FLOORPLAN" )
( cons "GE-FLOR-E02B$0$SE-COLS-STEL" "FLOORPLAN" )
( cons "GE-FLOR-E02B$0$AE-GLAZ" "FLOORPLAN" )
( cons "GE-FLOR-E02B$0$AE-WALL-SILL" "FLOORPLAN" )
( cons "GE-FLOR-E02B$0$AE-DOOR" "FLOORPLAN" )
( cons "GE-FLOR-E02B$0$AE-FLOR-CASE" "FURNITURE" )
( cons "GE-FLOR-E02B$0$AE-FLOR-CASE-OVHD" "FURNITURE" )
( cons "GE-FLOR-E02B$0$AE-FLOR-CASE-UNDR" "FURNITURE" )
( cons "GE-FLOR-E02B$0$AE-FLOR-EVTR" "MISC" )
( cons "GE-FLOR-E02B$0$AE-FLOR-HRAL" "FLOORPLAN" )
( cons "GE-FLOR-E02B$0$AE-WALL-JAMB" "FLOORPLAN" )
( cons "GE-FLOR-E02B$0$AE-AREA-OCCP" "ROOM TAG" )
( cons "GE-FLOR-E02B$0$AE-AREA-IDEN" "ROOM TAG" )
( cons "GE-FLOR-E02B$0$SE-GRID" "GRID LINES" )
( cons "GE-FLOR-E02B$0$PE-SANR-FIXT" "MISC" )
( cons "GE-FLOR-E02B$0$AE-EQPM" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$AE-EQPM-UNDR" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$AE-FLOR" "MISC" )
( cons "GE-FLOR-E02B$0$EE-POWR-EQPM" "AE ELECTRICAL" )
( cons "GE-FLOR-E02B$0$SE-WALL-CONC" "DefPoints" )
( cons "GE-FLOR-E02B$0$SE-COLS-CONC" "FLOORPLAN" )
( cons "GE-FLOR-E02B$0$AE-EQPM-OVHD" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$AE-WALL-PRHT" "FLOORPLAN" )
( cons "GE-FLOR-E02B$0$SE-JNTS-EXPJ" "DefPoints" )
( cons "GE-FLOR-E02B$0$FE-EQPM" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$ME-EQPM" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$ME-EQPM-OVHD" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$EE-POWR-EQPM-OVHD" "AE ELECTRICAL" )
( cons "GE-FLOR-E02B$0$AE-ANNO-STRS" "DefPoints" )
( cons "GE-FLOR-E02B$0$AE-FLOR-OTLN" "DefPoints" )
( cons "GE-FLOR-E02B$0$AE-FLOR-STRS-HRAL" "FLOORPLAN" )
( cons "GE-FLOR-E02B$0$PE-SANR-VENT" "MISC" )
( cons "GE-FLOR-E02B$0$SE-JNTS-CTLJ" "DefPoints" )
( cons "GE-FLOR-E02B$0$PE-STRM-RFDR" "MISC" )
( cons "GE-FLOR-E02B$0$AE-ROOF-OTLN" "DefPoints" )
( cons "GE-FLOR-E02B$0$AE-ROOF" "DefPoints" )
( cons "GE-FLOR-E02B$0$AE-FLOR-RAIS" "DefPoints" )
( cons "GE-FLOR-E02B$0$QE-EQPM" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$QE-EQPM-CLNG-SUSP" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$SE-EQPM-UNIS" "DefPoints" )
( cons "GE-FLOR-E02B$0$QE-EQPM-FLOR-ACCS" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$SE-BEAM-OVHD" "DefPoints" )
( cons "GE-FLOR-E02B$0$QE-EQPM-ISOC" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$QE-EQPM-CLNG" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$QE-EQPM-SWNG" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$QE-EQPM-BASE" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$QE-EQPM-CLER" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$QE-EQPM-CLNG-SUPP" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$QE-EQPM-CLNG-PATT" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$QE-FLOR-MGNT-ZONE" "FLOORPLAN" )
( cons "GE-FLOR-E02B$0$QE-EQPM-SFTY" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$AE-WALL-CAVI-SHLD" "FLOORPLAN" )
( cons "GE-FLOR-E02B$0$AE-ANNO-ADAR" "DefPoints" )
( cons "GE-FLOR-E02B$0$EE-POWR-URAC" "AE ELECTRICAL" )
( cons "GE-FLOR-E02B$0$IE-FURN" "FURNITURE" )
( cons "GE-FLOR-E02B$0$IE-FURN-PLNT" "FURNITURE" )
( cons "GE-FLOR-E02B$0$IE-FURN-SR" "FURNITURE" )
( cons "GE-FLOR-E02B$0$IE-FURN-SR-OVHD" "FURNITURE" )
( cons "GE-FLOR-E02B$0$IE-FURN-SR-UNDR" "FURNITURE" )
( cons "GE-FLOR-E02B$0$IE-FURN-WKSF" "FURNITURE" )
( cons "GE-FLOR-E02B$0$G-ANNO-MATC" "GRID LINES" )
( cons "GE-FLOR-E02B$0$A-WALL" "FLOORPLAN" )
( cons "GE-FLOR-E02B$0$A-DOOR" "DefPoints" )
( cons "GE-FLOR-E02B$0$A-FLOR-OVHD" "FURNITURE" )
( cons "GE-FLOR-E02B$0$A-FLOR-CASE" "FURNITURE" )
( cons "GE-FLOR-E02B$0$A-WALL-CAVI" "FLOORPLAN" )
( cons "GE-FLOR-E02B$0$A-EQPM-OVHD" "EQUIPMENT" )
( cons "GE-FLOR-E02B$0$A-FLOR-CASE-UNDR" "FURNITURE" )
( cons "GE-FLOR-E02B$0$A-AREA-OCCP" "DefPoints" )
( cons "GE-FLOR-E02C$0$AE-EQPM" "EQUIPMENT" )
( cons "GE-FLOR-E02C$0$AE-FLOR-CASE-OVHD" "FURNITURE" )
( cons "GE-FLOR-E02C$0$AE-DOOR" "FLOORPLAN" )
( cons "GE-FLOR-E02C$0$AE-FLOR-EVTR" "MISC" )
( cons "GE-FLOR-E02C$0$SE-GRID" "GRID LINES" )
( cons "GE-FLOR-E02C$0$AE-FLOR-STRS" "FLOORPLAN" )
( cons "GE-FLOR-E02C$0$AE-WALL" "FLOORPLAN" )
( cons "GE-FLOR-E02C$0$AE-GLAZ" "FLOORPLAN" )
( cons "GE-FLOR-E02C$0$PE-SANR-FIXT" "MISC" )
( cons "GE-FLOR-E02C$0$SE-COLS-CONC" "FLOORPLAN" )
( cons "GE-FLOR-E02C$0$SE-COLS-STEL" "FLOORPLAN" )
( cons "GE-FLOR-E02C$0$AE-WALL-CAVI" "FLOORPLAN" )
( cons "GE-FLOR-E02C$0$AE-FLOR-OVHD" "FLOORPLAN" )
( cons "GE-FLOR-E02C$0$SE-WALL-CONC" "FLOORPLAN" )
( cons "GE-FLOR-E02C$0$AE-FLOR" "FLOORPLAN" )
( cons "GE-FLOR-E02C$0$SE-WALL-CAVI" "FLOORPLAN" )
( cons "GE-FLOR-E02C$0$FE-EQPM" "EQUIPMENT" )
( cons "GE-FLOR-E02C$0$AE-FLOR-CASE-UNDR" "FURNITURE" )
( cons "GE-FLOR-E02C$0$AE-EQPM-UNDR" "EQUIPMENT" )
( cons "GE-FLOR-E02C$0$AE-ANNO-CNTR" "DefPoints" )
( cons "GE-FLOR-E02C$0$AE-AREA-IDEN" "ROOM TAG" )
( cons "GE-FLOR-E02C$0$AE-AREA-OCCP" "ROOM TAG" )
( cons "GE-FLOR-E02C$0$AE-ROOF-OTLN" "DefPoints" )
( cons "GE-FLOR-E02C$0$AE-ROOF" "DefPoints" )
( cons "GE-FLOR-E02C$0$AE-WALL-SILL" "FLOORPLAN" )
( cons "GE-FLOR-E02C$0$AE-FLOR-CASE" "FURNITURE" )
( cons "GE-FLOR-E02C$0$AE-WALL-JAMB" "FLOORPLAN" )
( cons "GE-FLOR-E02C$0$AE-FLOR-STRS-HRAL" "FLOORPLAN" )
( cons "GE-FLOR-E02C$0$PE-SANR-FLDR" "MISC" )
( cons "GE-FLOR-E02C$0$AD-BLDG" "DefPoints" )
( cons "GE-FLOR-E02C$0$G-ANNO-MATC" "GRID LINES" )
( cons "GE-FLOR-E02C$0$IE-FURN" "FURNITURE" )
( cons "E-FP-2D$0$A-WALL-FNSH" "FLOORPLAN" )
( cons "E-FIRE" "AE FIRE ALARM" )
( cons "G-ANNO-TTLB-REVS" "DefPoints" )
( cons "E-DP-2D$0$AE-AREA-IDEN" "ROOM TAG" )

( cons "TOPO-FENCE-200" "FENCE-200" )
( cons "HATCH-250" "HTCH-250" ) );list
);sq
( foreach item layerlist
( if ( and ( tblsearch "Layer" ( car item ) )
( not ( tblsearch "Layer" ( cdr item ) )) );a
( command "-Layer" "Rename" ( car item ) ( cdr item ) "" )
);i
);fe

( setq ss_newlayer ( ssget "X" ))
( while ( setq change_en ( ssname ss_newlayer 0 ))
( setq ss_newlayer ( ssdel change_en ss_newlayer ))
( if ( assoc ( cdr ( assoc 8 ( entget change_en ))) layerlist )
( entmod ( subst ( cons 8 ( cdr ( assoc ( cdr ( assoc 8 ( entget change_en ))) layerlist ))) ( assoc 8 ( entget change_en )) ( entget change_en ) ))
);i
);w

( foreach item layerlist
( if ( tblsearch "Layer" ( car item ) )
( command "-Layer" "Delete" ( car item ) "" )
);i
);fe
( princ "\nFinished:" )(princ ))
{code}

 

Message 7 of 80
brettgr
in reply to: Ajilal.Vijayan

Also I tried another drawing and got this message: 

 

Command: FIXMYLAYERS
-Layer
Current layer: "E-Powr-Circ"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: Rename
Enter old layer name: E-LITE-SWCH
Enter new layer name: AE ELECTRICAL Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]:
Command:
Finished:

 

But when I try the command again all it says is:

 

Command: FIXMYLAYERS
Finished:

Message 8 of 80
Ajilal.Vijayan
in reply to: brettgr

This seems to be fine.

 

After creating the old & new layer list it searches the layer table and renaming the old layer with the new name.

 

Can you post the drawing where you find the error which you stated in post # 6.

 

 

Message 9 of 80
dmfrazier
in reply to: brettgr

"My current layer is layer 0. So I don't think that is the issue, if I remember it right I don't have layer 0 being translated to anything."

 

I proposed reason #1 because I had not taken the time to analyze the code to see the order of operations.  It is now clear to me that the layer deleting is occurring as a last step, independent of the layer re-naming and the routine does not involve re-setting the current layer.  As long as layer 0 is current when you run the routine, then reason #1 would not apply.

 

"For the layer that might be used as a block or in a block is there a way the lisp can still change it with out exploding all blocks?"

 

The LISP can change the layer name regardless of what objects in the DWG are using it.

And it would not be necessary to "explode" all blocks.  If there are inserts of the blocks in the DWG, and they are not necessary, simply erase them.  If there are unnecessary block definitions, simply purge them.  If necessary block definitions are using layers you don't want them to use, you will have to re-define those blocks.  (Perhaps this kind of file clean-up would be best performed before running your LISP routine.)

 

"It shows that it can not delete E-POWER-EQPM, but when I search for E-POWR-EQPM I can not find the layer using quick select by layer name and I also can't purge the layer out out of the drawing either. So not sure where the layer is being used I'm guessing it is being used in a block."

 

Correct (that would be reason #2).

QSelect will not find objects "nested" within block definitions.  I believe the only way to ferret out which blocks are using which layer(s) is to REFEDIT (or BEDIT) each block definition.

Message 10 of 80
brettgr
in reply to: Ajilal.Vijayan

The drawing E1.2A is the drawing I believe I had that error. I also attached another drawing that I am also having issues with. I have yet to find a drawing that it will work on. Not sure if this has any effect but I am running autocad 2014.

Message 11 of 80
dmfrazier
in reply to: brettgr

"...I dont see why its having any issues. I really hope I get this thing to work it will save so much time converting drawings."

 

Aside from a few typos in the renaming part (pointed out by others), the routine is working exactly as it was apparently intended to work.  The section at the end...

 

(foreach item layerlist
  (if (tblsearch "Layer" (car item))
    (command "-Layer" "Delete" (car item) "")
  )

)

...is written to indiscriminately delete every layer in layerlist, with no error-checking mechanism other than the LAYER command's built-in error-checking (i.e. cannot delete current or in-use layers).  It seems the original programmer decided that was good enough for his/her purposes.  The error messages don't interrupt the routine, so it effectively "purges" the listed layers that are not in use or current.

 

If you were expecting something more like what LAYDEL does (i.e. deletes the objects as well as the layers), then perhaps pendean's suggestion is worth a try.  Otherwise, you could simply add  lines at the beginning to set layer 0 current, followed by a few PURGE Alls to clean up that (apparently) "unwanted" stuff before running the re-name part, which should eliminate the need to delete layers at the end (particularly if you were thinking of using LAYDEL, which may muck up some of the block defs you do want left in the DWG).

Message 12 of 80
Ajilal.Vijayan
in reply to: brettgr

The error is due to the objects are in use.

 

Instead of using this lisp can you consider using LAYTRANS.

It also have options to change the nested blocks as well.

 

Once you done the mapping in there, can save the mapping for future use also.

Message 13 of 80
brettgr
in reply to: Ajilal.Vijayan

I currently use LAYTRANS but with diffent prints coming from different architects the layers are different. That is why I was trying to use a lisp to have a large database and all I need to do is run the command and translating my layers would be done. I dont have to go through and add layers in the LAYTRANS command. Do you know of a different way that I can accomplish this?

Message 14 of 80
Ajilal.Vijayan
in reply to: brettgr

The Laytrans mapping can be saved to *.dws file.

 

You can save different architects mapping *.dws file and load that *.dws file instead of creating layer at each time.

Message 15 of 80
brettgr
in reply to: dmfrazier

Aside from a few typos in the renaming part (pointed out by others), the routine is working exactly as it was apparently intended to work.  The section at the end...


I must be looking at this to long I can't seem to see the typos. 

 

...is written to indiscriminately delete every layer in layerlist, with no error-checking mechanism other than the LAYER command's built-in error-checking (i.e. cannot delete current or in-use layers).  It seems the original programmer decided that was good enough for his/her purposes.  The error messages don't interrupt the routine, so it effectively "purges" the listed layers that are not in use or current.

 

But I was thinking this Lisp would rename all the layers to the layers I have specified in the program. (I am very new to doing Lisp programs) But the Lisp is not even renaming the layers, when I run it all the layers that were in the drawing are still there and nothing has been changed. 

 

Otherwise, you could simply add  lines at the beginning to set layer 0 current. followed by a few PURGE Alls to clean up that (apparently) "unwanted" stuff before running the re-name part,

 


I am very new to working with Lisp and writing code so at the moment I am unsure what to type to add that to the program.

Message 16 of 80
brettgr
in reply to: Ajilal.Vijayan

Is there a way to combine multiple .dws files? The reason I am asking is because each time we get a drawing from the architect it seems like there are alot of different layers and instead of figureing out which .dws goes with a certain architect it will be saved to a single .dws file?

Message 17 of 80
Ajilal.Vijayan
in reply to: brettgr

dws file is AutoCAD standard file.

dws is just an option.

 

You can use dwg and dwt also.

So insert multiple dwg/dws/dwt file into a single drawing, if you like to combine it.

Message 18 of 80
dmfrazier
in reply to: brettgr

"...I can't seem to see the typos."

 

One or two of the other responders noted one or two earlier. If you take a look back through the posts you'll see what I'm referring to.

 

"...But the Lisp is not even renaming the layers, when I run it all the layers that were in the drawing are still there and nothing has been changed."

 

I didn't realize the re-naming part didn't work for you.

 

I just tried the code (modified for my environment) and it does re-name the layers according to the layerlist.  I do get an error, but it's nothing like the errors you've reported.  If I run the code in pieces:

 

The "setq layerlist" part runs fine. The list is created.

 

The next part ("foreach layerlist", where the re-naming occurs) works fine. Layers are correctly renamed.

 

It's the next part (starting with "setq ss_newlayer") where I get this error:

 

; error: bad argument type: lselsetp

 

When I run this line: (setq ss_newlayer (ssget "X")), by itself, it returns "nil", which is what produces the error when the following code runs.

 

I'm not sure what the purpose of this part is, but it is expecting the "ss_newlayer" variable to have a non-nil value.  In my case this appears to be due to the fact that my drawing has no objects in it.

 

I don't have time right now (as much as I'd like) to analyze this any further, but if no one else jumps in here, I will get back to it when I can.

 

Message 19 of 80
hmsilva
in reply to: brettgr

brettgr,

I tested the code with your dwg's, without error...

As already been said, errors can happen when trying to delete a layer that is in use (current, in a block definition, ...)

Added some commands to your code, to attempt to minimize this type of error.

Try it, and let us know the result.

 

HTH

Henrique

EESignature

Message 20 of 80
brettgr
in reply to: hmsilva

Here is what my command prompt returns when I run the changes you made to the lisp. For some reason the layers are not being changed I dont see any layers that it was suppose to change. Would the way I load the lisp effect it or the version of Autocad have an effect on it? I go to appload and load it and add it to my startup suite. The version of autocad I have is 2014. 

 

Command: FIXMYLAYERS
Layer
Current layer: "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: T
Enter name list of layer(s) to thaw: * Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: ON
Enter name list of layer(s) to turn on: * Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: U
Enter name list of layer(s) to unlock or <select objects>: * Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: S
Enter layer name to make current or <select object>: 0 Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: Regen queued.
Command: Purge
Enter type of unused objects to purge [Blocks/DEtailviewstyles/Dimstyles/Groups/LAyers/LTypes/MAterials/MUltileaderstyles/Plotstyles/SHapes/textSTyles/Mlinestyles/SEctionviewstyles/Tablestyles/Visualstyles/Regapps/Zero-length geometry/Empty text objects/All]: LA Enter name(s) to purge <*>: Verify each name to be purged? [Yes/No] <Y>: n
No unreferenced layers found.
Command: FIXMYLAYERS
Unknown command "FIXMYLAYERS". Press F1 for help.
Command: -Layer
Current layer: "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: Rename
Enter old layer name: E-LITE-SWCH
Enter new layer name: AE ELECTRICAL Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]:
Command: Purge
Enter type of unused objects to purge [Blocks/DEtailviewstyles/Dimstyles/Groups/LAyers/LTypes/MAterials/MUltileaderstyles/Plotstyles/SHapes/textSTyles/Mlinestyles/SEctionviewstyles/Tablestyles/Visualstyles/Regapps/Zero-length geometry/Empty text objects/All]: LA Enter name(s) to purge <*>: Verify each name to be purged? [Yes/No] <Y>: n
No unreferenced layers found.
Command: FIXMYLAYERS
Unknown command "FIXMYLAYERS". Press F1 for help.
Command: -Layer
Current layer: "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: Delete
Enter layer(s) to delete: G-ANNO-TTLB The selected layers could not be deleted.
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]:
Command: -Layer
Current layer: "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: Delete
Enter layer(s) to delete: E-POWR-EQPM The selected layers could not be deleted.
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]:
Command:
Finished:

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost