@asherjoh wrote:
Just to be clear, this lisp was supposed to allow me to put one layer over another with a couple clicks of the mouse. If anyone can read it, does it look like that's what it does? Plus I don't know why it says water, gas and electric. Guess I learned my lesson that lisps can cause problems if you don't know what your doing.
it does.
The function should put the entities on the layers Water, Gas, Electric, Text and/or Dimensions under any entities on the same layer as the selected entity.
...so it's a bit strange that you don't know why it uses those specific layer names. Since only those will be affected. (& i wonder what happens if the selected entity is on one of those layers ... )
I'll try to explain the function's inner workings...
(if (and (setq en (car (entsel "\nSelect object on reference layer: ")))
- here it askes to select an object/entity (& the function will only continue if there is an object selected)
(setq sr (ssget "_X" (list (assoc 8 (entget en))))))
- here it retrieves the entities on the same layer as the selected one (DXF code 8 = layername)
(foreach layer '("Water" "Gas" "Electric" "Text" "Dimensions")
- here it repeats the following code for each layername given. So: Water Gas Electric Text & Dimensions are the only layers affected
(if (and (setq data (tblsearch "LAYER" layer)) ; layer exists
- as the comment states, here it checks if the layer (water, gas, etc.) realy exists
(zerop (logand 4 (cdr (assoc 70 data)))) ; layer unlocked
- As the comment states, here it checks if the layer is unlocked
(setq ss (ssget "_X" (list (cons 8 layer)))) ; layer has objects
- here it retrieves any entities on that layer
)
- end of conditions (if)
- so the next line only executes when the layer (Water, Gas, etc.) exists, is unlocked & has entities
(command "_.draworder" ss "" "_u" sr ""))))
- here it will change the draworder for all entities from selection set "ss" (the entities on layer Water/Gas/etc.)
- UNDER the entities from selection set "sr" (the entities on the same layer as the selected entity
(princ)
- supresses nil
)
- end of the repeating code for each layer (Water/Gas/etc.)