(Update) Is there a lisp routine to switch layers back and forth?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everybody,
Im back. So I did a lot of research trying to figure out how to get this program to run. Switching one layer (S-BEAM-STEEL) to an existing layer with a different color (E-BEAM-STEEL). I tried messing a bit with the laymrg command but wasn't getting any luck. after hours of looking I found this one forum with a code that could work for me. I tried manipulating it again and again to get to do what want but didnt get to far. So far the code creates the existing layer but i cant figure out how to revert back to the original with the same command. Would i essentially have to repeat this whole code just exclude the EXT part?
Other things im trying to figure out
Is there a way where instead of naming the existing layer "S-ANNO-BREAK-EXST", it is named "E-ANNO-BREAK"?
Also, instead of selecting one line/object at a time is there a way to select multiple and change them at the same time? The code below was posted on the original forum but i couldnt get it to work. I'll admit i didnt spend to much on this part. I was focused to much on the other issues.
AA:ExlEntityToChange (entsel "\nSelect the entity to move to existing:") (princ "\n"\nSelect the entity to move to existing:") AA:ExlEntityToChange (ssget) (princ "\n"\nSelect the entity to move to existing:") AA:ExlEntityToChange (ssget '((0 . "INSERT")) )
Im a newbie and getting better at reading code but for the life of me i cant figure out whats going on in PART 2 of the code.
Any help is welcomed and appreciated. Thanks in advance.
Link to the original
http://forums.augi.com/showthread.php?167577-Existing-layer-lisp
;**********************************************************PART-1************************************************************************ (defun c:TEST ( / AA:ExlClayer AA:ExlEntityToChange AA:ExlEntityName AA:ExlEntityLayer AA:ExlNewLayerName AA:ExlNewLayerColor) (setq AA:ExlClayer (getvar "clayer") AA:ExlEntityToChange (entsel "\nSelect the entity to move to existing:") ) (while (or (null AA:ExlEntityToChange)) (princ "\nPlease try again.") (setq AA:ExlEntityToChange (entsel "\nSelect the entity to move to existing:")) ) ;**********************************************************PART-2************************************************************************ (setq AA:ExlEntityName (car AA:ExlEntityToChange) AA:ExlEntityLayer (cdr (assoc 8 (entget AA:ExlEntityName))) ) (if (wcmatch AA:ExlEntityLayer "*-EXST,0,Defpoints,InfoStamp,MHatch,EHatch,Alvine,MCalc,ETXT,Ttxt,Wipeout,Building") (progn (princ "\nThe entity is already on an existing layer!\nPlease try again.\n") (AA:ExlClearVariables) (exit) (princ)) ;**********************************************************PART-4************************************************************************ (setq AA:ExlNewLayerName (strcat AA:ExlEntityLayer "-EXST")) ) (LayerColorMatrix) (setvar "cmdecho" 0) (if (not (tblsearch "Layer" AA:ExlNewLayerName)) (command "-layer" "make" AA:ExlNewLayerName "color" AA:ExlNewLayerColor "" "lt" AA:ExlLineType "" "") ) (command ".chprop" AA:ExlEntityToChange "" "layer" AA:ExlNewLayerName "") (setvar "clayer" AA:ExlClayer) (setvar "cmdecho" 1) (AA:ExlClearVariables) (princ) ) ;**********************************************************PART-5************************************************************************ (defun LayerColorMatrix ( / AA:ExlLayerList) (setq AA:ExlLayerList (list "S-ANNO-BREAK-EXST" "S-ANNO-GRID-EXST" ) ) (if (not (member AA:ExlNewLayerName AA:ExlLayerList)) (progn (setq AA:ExlNewLayerColor "216" AA:ExlLineType "Continuous" AA:ExlLayerReport "No color definition has been found for this layer.\n\nA layer called: ") (setq AA:ExlLayerReport (strcat AA:ExlLayerReport AA:ExlNewLayerName " has been created with the color 216.")) ) (princ) ) ;**********************************************************PART-6************************************************************************ (if (= AA:ExlNewLayerName "S-ANNO-BREAK-EXST") (setq AA:ExlNewLayerColor "135" AA:ExlLineType "Continuous") (princ)) (if (= AA:ExlNewLayerName "S-ANNO-GRID-EXST") (setq AA:ExlNewLayerColor "216" AA:ExlLineType "Continuous") (princ)) (princ) ) ;**********************************************************PART-7************************************************************************ (defun AA:ExlClearVariables () (setq AA:ExlClayer nil AA:ExlEntityToChange nil AA:ExlEntityName nil AA:ExlEntityLayer nil AA:ExlNewLayerName nil AA:ExlNewLayerColor nil AA:ExlLayerList nil AA:ExlLineType nil) (princ) )