Jump to content

need a lisp fixed if some one would be so kind..


Recommended Posts

Posted

basically i have a lisp and it renames layers.

this will be running on mupitaple drawings through a script but at layer E-APPL i get error: bad argument type: lselsetp nil

this in not even halfway through my layers.

any ideas ?

 

;;function to rename a layer.
;;if old layer exists, and new layer doesn't exist, the old layer is simply renamed.
;;if old layer exists, and new layer is already there, it takes everything on old layer and puts them on new layer.
;;if old layer doesn't exist, it does nothing.
(defun renlay (ol nl / ss i ent )
 (cond ((and (tblsearch "layer" ol) (not (tblsearch "layer" nl))) 
 (command "._rename" "la" ol nl)
)
((and (tblsearch "layer" ol)(tblsearch "layer" nl))
  (setq ss (ssget "x" (list (cons 8 ol))))
  (setq i -1)
   (repeat (sslength ss)
      (setq ent (entget (ssname ss (setq i (1+ i))))
     ent (subst (cons 8 nl) (cons 8 (cdr (assoc 8 ent))) ent)
      )    
      (entmod ent)
          )
)
((not (tblsearch "layer" ol))
  (prompt (strcat "\nLayer " ol " not found. "))
       )
 )
 (princ)
)
;;example
(defun c:layre ()
  ( renlay "21" "remove" )
  ( renlay "32" "A-RNAM" )
  ( renlay "33" "A-RNUM" )
  ( renlay "37" "A-ANNO" )
  ( renlay "59" "A-RNAM" )
  ( renlay "65" "L-WALK" )
  ( renlay "72" "L-WALK" )
  ( renlay "140" "L-PLANT-TREE" )
  ( renlay "228" "remove" )
  ( renlay "230" "remove" )
  ( renlay "250" "S-STEEL" )
  ( renlay "420" "L-WALK" )
  ( renlay "450" "A-ROOF" )
  ( renlay "461" "A-WIND" )
  ( renlay "465" "A-DOOR" )
  ( renlay "470" "A-WIND" )
  ( renlay "480" "A-DOOR" )
  ( renlay "600" "F-FURN-FIXT" )
  ( renlay "610" "F-FURN-FREE" )
  ( renlay "737" "P-PLUM" )
  ( renlay "850" "M-AIRCON" )
  ( renlay "920" "remove" )
  ( renlay "$AUDIT-BAD-LAYER" "remove" )
  ( renlay "000HATCH" "remove" )
  ( renlay "021_A1BASE" "remove" )
  ( renlay "021-A1-SHEET" "remove" )
  ( renlay "021-SHEET" "remove" )
  ( renlay "030-DIMENSIONS" "A-ANNO-DIMS" )
  ( renlay "032_NAME" "A-RNAM" )
  ( renlay "032-RNAME" "A-RNAM" )
  ( renlay "032ROOMNAMES" "A-RNAM" )
  ( renlay "032-ROOMNAMES" "A-RNAM" )
  ( renlay "033_ROOM-NUMBERS" "A-RNUM" )
  ( renlay "033-RNUMB" "A-RNUM" )
  ( renlay "034_FLOOR-FINISHES" "A-FLOR-PAT" )
  ( renlay "034-FLOOR_FIN" "A-FLOR-PAT" )
  ( renlay "034-FLOOR-FINISHES" "A-FLOOR-PAT" )
  ( renlay "035_DETAIL-REF-NO" "remove" )
  ( renlay "036_SECTION-REF-NO" "remove" )
  ( renlay "037_TEXT" "A-ANNO-TXT" )
  ( renlay "037_TEXT-PARTITION" "A-ANNO-TXT" )
  ( renlay "037-ARCH_TEXT" "A-RNUM" )
  ( renlay "037-ELC-TEXT" "remove" )
  ( renlay "037GENERALTEXT" "A-ANNO-TXT" )
  ( renlay "037-NOTES" "remove" )
  ( renlay "037-REFERENCE" "LDADEL" )
  ( renlay "037-TEXT" "A-ANNO-TXT" )
  ( renlay "040BUILDINGGRID" "A-GRID" )
  ( renlay "062_HATCH-BRICK" "A-WALL" )
  ( renlay "062_HATCH-MASONRY" "A-WALL" )
  ( renlay "072_BOUNDARY" "L-SITE" )
  ( renlay "072_FENCE" "L-SITE-FENC" )
  ( renlay "072_PARKING" "L-WALK" )
  ( renlay "072_PAVING" "L-WALK" )
  ( renlay "072_RETAINING-WALL" "A-WALL" )
  ( renlay "072_SITE" "L-SITE" )
  ( renlay "072_SITE-FEATURES" "L-SITE" )
  ( renlay "072-190" "remove" )
  ( renlay "072-SITE" "L-SITE" )
  ( renlay "140-VEGETATION" "L-PLANT-PLAN" )
  ( renlay "220_CONCRETE" "S-CON" )
  ( renlay "230_MASONRY-WALLS" "A-WALL" )
  ( renlay "230_WALLS_MASONRY" "A-WALL" )
  ( renlay "230_WALLS_STUDS" "A-WALL-STUD" )
  ( renlay "230-WALL" "A-WALL" )
  ( renlay "231_EX-WALLS" "A-WALL" )
  ( renlay "231-EXISTINGWALLS" "A-WALL" )
  ( renlay "250_COL" "S-COL" )
  ( renlay "250_STRUCTURAL-STEEL" "S-STEEL" )
  ( renlay "260_METALWORK" "S-STEEL" )
  ( renlay "280NEWGLAZING" "A-WIND" )
  ( renlay "290_STAIRS" "A-STAIR" )
  ( renlay "420_PAVING" "L-WALK" )
  ( renlay "420-PAVING" "L-WALK" )
  ( renlay "444_PARTITION" "A-WALL" )
  ( renlay "444_STUD" "A-WAL" )
  ( renlay "444NEWPARTITON" "A-WALL" )
  ( renlay "445-EXIST_PART" "A-WALL" )
  ( renlay "447_SCREENS" "remove" )
  ( renlay "450_DOWNPIPIES" "remove" )
  ( renlay "450_ROOFING" "A-ROOF" )
  ( renlay "450-ROOF" "A-ROOF" )
  ( renlay "459_SUSPEMDED-CEILING" "remove" )
  ( renlay "459-CEILING" "remove" )
  ( renlay "459CEILINGEXISITNGLIGHT" "remove" )
  ( renlay "459-NEW" "remove" )
  ( renlay "461_WINDOWS" "A-WIND" )
  ( renlay "461-EXTERNAL" "A-WIND" )
  ( renlay "461-OBSERV" "A-WIND" )
  ( renlay "461-WIND" "A-WIND" )
  ( renlay "462_EX-WINDOWS" "A-WIND" )
  ( renlay "465_DOORS" "A-DOOR" )
  ( renlay "465_DOORS" "A-DOOR" )
  ( renlay "465-444" "A-DOOR" )
  ( renlay "465-DOORS" "A-DOOR" )
  ( renlay "465NEWDOORS" "A-DOOR" )
  ( renlay "466_EX-DOORS" "A-DOOR" )
  ( renlay "466-444" "A-DOOR" )
  ( renlay "467_WINDOWS-REMOVED" "remove" )
  ( renlay "552TILES" "remove" )
  ( renlay "553-VINYL" "A-FLOR-PAT" )
  ( renlay "600_FIXED-FURNITURE" "I-FURN-FIXT" )
  ( renlay "600_FURN_FIXED" "I-FURN-FIXT" )
  ( renlay "600-FFURN" "A-FUN-FREE" )
  ( renlay "600-FIXED-FURN" "F-FURN-FIXT" )
  ( renlay "600FIXEDFURNITURE" "F-FURN" )
  ( renlay "600-FURNITURE_FIXED" "F-FURN-FIXT" )
  ( renlay "601_EX-FIXED-FURNITURE" "I-FURN-FIXT" )
  ( renlay "610-FURNITURE-LOOSE" "F-FURN-FREE" )
  ( renlay "610-LOOSE_FURN" "F-FURN-FREE" )
  ( renlay "610LOOSEFURNITURE" "F-FURN-FREE" )
  ( renlay "611_FURN-NIC" "remove" )
  ( renlay "650_NEW-PLUMBING" "P-PLUM" )
  ( renlay "651_EX-PLUMBING" "P-FIXT" )
  ( renlay "700-HYD" "P-PLUM" )
  ( renlay "700-PLUMBING" "P-PLUM" )
  ( renlay "737_PLUMB" "P-PLUM" )
  ( renlay "737_PLUMBING" "P-FIXT" )
  ( renlay "737-PLUMBING-FIX" "P-PLUM" )
  ( renlay "783-FIRE-EX" "remove" )
  ( renlay "790-COMP" "remove" )
  ( renlay "850_MECH" "M-AIRCON" )
  ( renlay "850-MECHANICAL" "A-MEC" )
  ( renlay "920_ROADS" "remove" )
  ( renlay "922-ROAD" "remove" )
  ( renlay "930-SEMI-ENCL-SPACES" "remove" )
  ( renlay "A_Col" "S-COL" )
  ( renlay "A_DOOR" "A-DOOR" )
  ( renlay "A_Door" "A-DOOR" )
  ( renlay "A_Doors" "A-DOOR" )
  ( renlay "A_Furn" "I-FURN" )
  ( renlay "A_Paving" "L-WALK" )
  ( renlay "A_Roof" "A-ROOF" )
  ( renlay "A_Sani" "P-PLUM" )
  ( renlay "A_Text" "A-ANNO-TEXT" )
  ( renlay "A_Walls" "A-WALL" )
  ( renlay "A_WIND" "A-WIND" )
  ( renlay "A_Window" "A-WIND" )
  ( renlay "A1-BORDER" "remove" )
  ( renlay "A1-NPOINT" "remove" )
  ( renlay "A1-SHEET" "remove" )
  ( renlay "A1-TITLE" "remove" )
  ( renlay "A-Anno-Scrn" "remove" )
  ( renlay "A-Back-Colr" "remove" )
  ( renlay "A-BASE" "A-WALL" )
  ( renlay "A-BEAM" "S-COL" )
  ( renlay "A-CE-GE" "remove" )
  ( renlay "A-CEIL" "remove" )
  ( renlay "A-CE-WA" "remove" )
  ( renlay "ACOL" "S-COL" )
  ( renlay "A-COL" "S-COL" )
  ( renlay "A-COL-CONC" "S-COL-CONC" )
  ( renlay "A-COL-STEEL" "S-COL-STEEL" )
  ( renlay "A-CONC" "S-COL-CONC" )
  ( renlay "A-DE-GE" "remove" )
  ( renlay "A-DE-HA" "remove" )
  ( renlay "ADOOR" "A-DOOR" )
  ( renlay "ADOOR" "A-DOOR" )
  ( renlay "ADOOR" "A-DOOR" )
  ( renlay "A-EL-GE" "remove" )
  ( renlay "A-EL-GE1" "remove" )
  ( renlay "A-EL-GE2" "remove" )
  ( renlay "A-EL-HA" "remove" )
  ( renlay "AFIRE" "A-FIRE" )
  ( renlay "AFIRE" "F-FIRE" )
  ( renlay "AFIXT" "I-FURN-FIXT" )
  ( renlay "AFIXT" "A-FIXT" )
  ( renlay "AFIXT" "A-FIXT" )
  ( renlay "A-FL-AREABDRY" "remove" )
  ( renlay "A-FL-AREADEPT" "remove" )
  ( renlay "A-FL-AREARM" "remove" )
  ( renlay "A-FL-DI" "remove" )
  ( renlay "A-FL-DI1" "remove" )
  ( renlay "A-FL-DO" "remove" )
  ( renlay "A-FL-GE" "remove" )
  ( renlay "A-FL-GRID" "remove" )
  ( renlay "A-FL-HA" "remove" )
  ( renlay "AFLOOR" "A-FLOOR" )
  ( renlay "A-FLOOR-FIN" "A-FLOOR" )
  ( renlay "A-FLOOR-FINISH" "A-FLOOR" )
  ( renlay "AFLOR" "A-FLOOR" )
  ( renlay "A-FL-ST" "remove" )
  ( renlay "A-FL-TE" "remove" )
  ( renlay "A-FL-TE1" "remove" )
  ( renlay "A-FL-TE2" "remove" )
  ( renlay "A-FL-WI" "remove" )
  ( renlay "A-FURN" "I-FURN-FIXT" )
  ( renlay "A-FURN-FIXED" "I-FURN-FIXT" )
  ( renlay "A-FURN-LOOSE" "I-FURN-FREE" )
  ( renlay "A-GE-AREABA" "remove" )
  ( renlay "A-GE-GR" "remove" )
  ( renlay "A-GE-HA" "remove" )
  ( renlay "A-GE-TE" "remove" )
  ( renlay "A-GE-TE1" "remove" )
  ( renlay "A-GE-TE2" "remove" )
  ( renlay "AGLAS" "A-WIND" )
  ( renlay "AGLAS" "A-QIND" )
  ( renlay "AGLAS" "A-WIND" )
  ( renlay "AGRID" "A-GRID" )
  ( renlay "A-HANDRAIL" "A-FLOR-HRAL" )
  ( renlay "A-METALWK" "remove" )
  ( renlay "annot - demolition" "remove" )
  ( renlay "annot proposed" "remove" )
  ( renlay "A-PART" "A-WALL-MOVE" )
  ( renlay "APATH" "A-PATH" )
  ( renlay "A-PLUMB" "P-PLUM" )
  ( renlay "APPLIANCE" "remove" )
  ( renlay "A-RAMP" "A-FLOR-LEVL" )
  ( renlay "A-RDOOR" "A-DOOR" )
  ( renlay "A-RM-AREA" "A-AREA" )
  ( renlay "A-RM-AREA" "A-AREA" )
  ( renlay "A-RMNAM" "A-RNAM" )
  ( renlay "ARNAM" "A-RNAM" )
  ( renlay "ARNUM" "A-RNUM" )
  ( renlay "A-RO-EA" "remove" )
  ( renlay "A-RO-GE" "remove" )
  ( renlay "A-RO-HA" "remove" )
  ( renlay "AROOF" "A-ROOF" )
  ( renlay "A-ROOM NUMBERS" "remove" )
  ( renlay "A-ROOM-LEGEND" "remove" )
  ( renlay "A-SANIT" "P-FIXT" )
  ( renlay "A-SCALE 100" "remove" )
  ( renlay "As-Constructed" "remove" )
  ( renlay "A-SD-MASSSPCE" "remove" )
  ( renlay "ASHADE" "remove" )
  ( renlay "ASHADE" "remove" )
  ( renlay "A-STAIR-CONC" "A-STAIR" )
  ( renlay "A-ST-CO" "remove" )
  ( renlay "A-ST-HA" "remove" )
  ( renlay "ATEXT" "A-ANNO-TEXT" )
  ( renlay "A-TEXT" "A-ANNO-TEXT" )
  ( renlay "A-TXT" "A-ANNO-TXT" )
  ( renlay "A-TXT" "A-ANNO-TEXT" )
  ( renlay "AUCA" "A-UCA" )
  ( renlay "A-WA-GE" "remove" )
  ( renlay "A-WA-HA" "remove" )
  ( renlay "AWALL" "A-WALL" )
  ( renlay "centrline" "remove" )
  ( renlay "columns" "S-COL" )
  ( renlay "Dimensions" "A-ANNO-DIM" )
  ( renlay "DOOR" "A-DOOR" )
  ( renlay "DOOR" "A-DOOR" )
  ( renlay "door schedule" "remove" )
  ( renlay "doors" "A-DOOR" )
  ( renlay "E-APPL" "remove" )
  ( renlay "E-CbltHatch" "remove" )
  ( renlay "E-DISTRUBUTION" "E-POWER-SWBD" )
  ( renlay "E-ELECT" "E-POWER" )
  ( renlay "E-Halo-High" "remove" )
  ( renlay "E-Halo-Subd" "remove" )
  ( renlay "elec" "E-ELEC" )
  ( renlay "E-Lite-Detail" "remove" )
  ( renlay "E-Lite-Diagonal" "remove" )
  ( renlay "Extg" "remove" )
  ( renlay "FENCE" "L-SITE-FENC" )
  ( renlay "FIREEQUIP" "remove" )
  ( renlay "FIXTURES" "I-FURN-FIXT" )
  ( renlay "Fixtures" "F-FURN-FIXT" )
  ( renlay "FRAME" "A-ANNO" )
  ( renlay "FRAME" "remove" )
  ( renlay "FURN" "I-FURN" )
  ( renlay "FURNITURE" "I-FURN-FIXT" )
  ( renlay "furniture" "A-FURN-FREE" )
  ( renlay "G-Anno-Nplt" "remove" )
  ( renlay "G-Bgrd-Std-Scrn" "remove" )
  ( renlay "GRID" "A-GRID" )
  ( renlay "HANDRAIL" "A-FLOR-HRAL" )
  ( renlay "HATCH" "A-HATCH" )
  ( renlay "hatch - new beams" "remove" )
  ( renlay "hatch infill" "remove" )
  ( renlay "Hidden" "remove" )
  ( renlay "HYDRAULICS" "I-FURN-FIXT" )
  ( renlay "LANDSCAPE" "L-SITE" )
  ( renlay "LANDSCAPE" "L-SITE" )
  ( renlay "Layer1" "remove" )
  ( renlay "MASONRY" "A-WALL" )
  ( renlay "M-DuctHatch" "remove" )
  ( renlay "M-Halo-High" "remove" )
  ( renlay "M-Halo-Subd" "remove" )
  ( renlay "NEW" "remove" )
  ( renlay "NORTH" "remove" )
  ( renlay "PATH" "L-WALK" )
  ( renlay "PCCD200P5$0$A_Base Plan$0$037_GenTxt 0100" "A-ANNO-TEXT" )
  ( renlay "PCCD200P5$0$A_Base Plan$0$220_CONC" "S-COL-CONC" )
  ( renlay "PCCD200P5$0$A_Base Plan$0$220_Existing Conc" "S-COL-CONC" )
  ( renlay "PCCD200P5$0$A_Base Plan$0$231_Column Conc" "S-COL-CONC" )
  ( renlay "PCCD200P5$0$A_Base Plan$0$231_Existing Fixtures" "A-FIXT" )
  ( renlay "PCCD200P5$0$A_Base Plan$0$231_Existing Walls" "A-WALL" )
  ( renlay "PCCD200P5$0$A_Base Plan$0$260_Balustrade" "A-FLOR-HRAL" )
  ( renlay "PCCD200P5$0$A_Base Plan$0$465_DOOR" "A-DOOR" )
  ( renlay "PCCD200P5$0$A_Base Plan$0$465_Door Matt" "A-DOOR" )
  ( renlay "PCCD200P5$0$A_Base Plan$0$730_Sump" "remove" )
  ( renlay "PCCD200P5$0$A_Base Plan$0$737_Fixture Sanitary" "P-PLUM" )
  ( renlay "PCCD200P5$0$A_Base Plan$0$741_Fire HoseReel" "F-FIRE" )
  ( renlay "PCCD200P5$0$A_Furniture Plan$0$600_Fixed Furniture" "I-FURN-FIXT" )
  ( renlay "PCCD200P5$0$A_Furniture Plan$0$610_Loose Furniture B" "I-FURN-FREE" )
  ( renlay "PCCD200P5$0$A_Furniture Plan$0$A Joinery" "I-FURN" )
  ( renlay "PCCD200P5$0$A_Partition Plan$0$032_Room Names" "A-RNAM" )
  ( renlay "PCCD200P5$0$A_Partition Plan$0$231_Existing Fixtures" "A-DOOR" )
  ( renlay "PCCD200P5$0$A_Partition Plan$0$440_Xrefs" "remove" )
  ( renlay "PCCD200P5$0$A_Partition Plan$0$444_New Partitions" "A-WALL-PATT" )
  ( renlay "PCCD200P5$0$A_Partition Plan$0$461_Window" "A-WIND" )
  ( renlay "PCCD200P5$0$A_Partition Plan$0$465_DOOR" "A-DOOR" )
  ( renlay "PCCD200P5$0$A_Partition Plan$0$600_Fixed Furniture" "I-FURN-FIXT" )
  ( renlay "PCCD200P5$0$A_Partition Plan$0$737_Fixture Sanitary" "P-PLUM" )
  ( renlay "PCCD200P5$0$A_Partition Plan$0$A Column Conc" "S-COL-CONC" )
  ( renlay "PCCD200P5$0$A_Partition Plan$0$A Furniture Equipment" "I-FURN" )
  ( renlay "PCCD200P5$0$A_Partition Plan$0$A Joinery" "A-WALL" )
  ( renlay "PCCD200P5$0$A_Partition Plan$0$A Wall Int" "A-WALL" )
  ( renlay "PCCD200P5$0$A_Partition Plan$0$A Wall Int Glazed" "A-WALL" )
  ( renlay "PCCD200P5$0$A_Partition Plan$0$ST_Door" "A-DOOR" )
  ( renlay "PCCD200P5$0$A_Partition Plan$0$ST_Fixture Sanitary Hardware" "P-PLUM" )
  ( renlay "PCCD200P5$0$I_PL-GA_01_0100$0$032_Room Names" "A-RNAM" )
  ( renlay "PERGOLA" "L-SITE-DECK" )
  ( renlay "PLUMB" "P-PLUM" )
  ( renlay "PLUMBING" "P-PLUM" )
  ( renlay "REVDATE" "remove" )
  ( renlay "RNUM" "A-RNUM" )
  ( renlay "ROADWAY" "remove" )
  ( renlay "STEEL" "A-COL" )
  ( renlay "STUD" "A-WALL" )
  ( renlay "tblock" "remove" )
  ( renlay "TERRAZZO" "A-WALL" )
  ( renlay "TEXT" "A-ANNO" )
  ( renlay "Text - c'work" "remove" )
  ( renlay "title block" "remove" )
  ( renlay "TTLB" "remove" )
  ( renlay "TXT25" "A-RNAM" )
  ( renlay "TXT35" "A-RNAM" )
  ( renlay "VERANDAH" "L-SITE-DECK" )
  ( renlay "WALL" "A-WALL" )
  ( renlay "walls" "A-WALL" )
  ( renlay "WINDOW" "A-WIND" )
  ( renlay "windows" "A-WIND" )
  ( renlay "X-Anno-Conn" "remove" )
 )

Posted

Please check that in your list you used the same new name for more than one remaning case; at the time the second case is reached, there is already a layer with that name.

(renlay "21" [color=red]"remove"[/color])
...
(renlay "228" [color=red]"remove"[/color])
(renlay "230" [color=red]"remove"[/color])

Posted

the problem is i may need to put different layers to remove as laiter in the script i will be removing any layers on the layer remove??

Posted

Then try something like:

(renlay "21" "remove1")
...
(renlay "228" "remove2")
(renlay "230" "remove3")

Posted

if thats the only way around it, can my lisp to delete objects on remove layer be changed to delete objects that have remove in there layer name so i dont have one a lisp for each layer called remove, remove 1 ect.

 

(defun C:rmly (/ SSetLayer)
  (setq SSetLayer (ssget "_X" '((8 . "remove"))))
  (if SSetLayer
 (command "._Erase" SSetLayer "")
  )
  (princ)
)

Posted

The error in the code from first post occurs when it try to merge the content of layers with the same projected new name; the line below will return nil if processed layer (old name) is empty.

(setq ss (ssget "x" (list (cons 8 ol))))

Thus the error when try to process the presumed selection set - try instead:

[color=red](if [/color](setq ss (ssget "x" (list (cons 8 ol))))
[color=red] (progn[/color]
 (setq i -1)
 (repeat (sslength ss)
  (setq ent (entget (ssname ss (setq i (1+ i))))
        ent (subst (cons 8 nl) [s][color=red](cons 8 (cdr [/color][/s](assoc 8 ent)[s][color=red]))[/color][/s] ent)
  )    
  (entmod ent)
 )
[color=red] )[/color]
[color=red])[/color]

What should happen with processed layer in this case?

Posted

Mircea yet again you have saved my bacon.. i could kiss you.. thanks so much.. :D

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...