Author Topic: Lisp to toggle layer only works for blocks unless undo/redo  (Read 955 times)

0 Members and 1 Guest are viewing this topic.


  • Mosquito
  • Posts: 18
Ok, this is a weird one.  I can't imagine why this would be happening. 

I work for a medical device supplier in site planning.  We have a bunch of layers that all start with a number and we have several layer states based on what should show up on plan sheets and a lisp to switch between them.  I just wrote a lisp (based on this thread: that I want to use to toggle a layer on and off so, for instance, if I'm looking at the s1 layer state I can toggle on/off the 740 layer.

What's weird is that, for most layer states, my lisp only works for entities on the toggled layer that are inside a block, but not for standalone polylines.  What's even weirder is that if I draw a line, then undo it, then undo the lisp, then hit redo, everything shows up.  Now why would it work when redone, but not when called normally?!?  Also, if I start from the "FIN" layer state, the lisp works as expected.

Now if somebody wants to try and replicate the error, I've made non-confidential files that you can use.  So you'll open the "toggle test" drawing and load "toggle layer.lsp" and "Layer States - DXR.lsp".  If you type "fin" to get to the final layer state, you use the command "tl" to toggle layers 740 or 720 or 799.  But if you type "s1" to get to that layer state and try to toggle those layers, you won't see all the linework that you should.

I know this one's really convoluted so if anybody actually makes an attempt at it I will be very very grateful because this is driving me crazy and I have no clue where to even start.  TIA