Author Topic: Reverse Layers  (Read 6500 times)

0 Members and 1 Guest are viewing this topic.

daron

  • Guest
Re: Reverse Layers
« Reply #15 on: February 06, 2008, 11:54:56 AM »
Well, apparently bit flags are the back door to that problem. Funny thing is, you can attempt to draw and it will look like you are actually drawing something, but when you thaw and turn the layer back on, nothing shows up, at least not for me. I like that back door. It opens up lots of ideas: Like, is it possible to alter the coordinates of objects that are on a frozen layer, without thawing that layer?

JohnK

  • Administrator
  • Seagull
  • Posts: 10638
Re: Reverse Layers
« Reply #16 on: February 06, 2008, 01:06:07 PM »
Well, apparently bit flags are the back door to that problem. Funny thing is, you can attempt to draw and it will look like you are actually drawing something, but when you thaw and turn the layer back on, nothing shows up, at least not for me. I like that back door. It opens up lots of ideas: Like, is it possible to alter the coordinates of objects that are on a frozen layer, without thawing that layer?

I dunno, never tried. Ive messed with objects set to "not visible" but never frozen. ...Give it a whirl and report back.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

daron

  • Guest
Re: Reverse Layers
« Reply #17 on: February 06, 2008, 02:34:07 PM »
That's strange. I took Quamper's circle problem froze the 0 layer using your function and attempted to increase the size of all the radii by 1. ACAD acted like it performed the function, but didn't. However, using your function again to thaw everything, the circles don't show up. If I use the same ssget function that selected them when they were frozen to collect them again, they are selected and in the database, but regen won't force them to show up. On that thought, I checked for flipped bit flags and tested them again, changing dxf code 67 from 0 to... 0 and they appeared. No idea why, but I did learn that I can't alter an object that is frozen, even through the back door.
Here's the code I used for changing the radii:
Code: [Select]
(setq ss (ssget "x" (list (cons 0 "CIRCLE"))))
(setq cnt (1- (sslength ss)))
(while (> cnt -1)
 (setq ename (ssname ss cnt))
       cnt (1- cnt)
       elist (entget ename)
       alter (subst (1+ (cdr (assoc 40 elist))) (assoc 40 elist) elist))
     (entmod alter)
     (entupd ename)
     )

JohnK

  • Administrator
  • Seagull
  • Posts: 10638
Re: Reverse Layers
« Reply #18 on: February 06, 2008, 04:49:57 PM »
huh? Cool.

Here is a full blown demo of what Daron is referring to.

Code: [Select]
( (lambda ( / )

    ;; support procedures

    (defun tog_layer_stuff ( layername / layer lsylst props off freeze lock )

      ;; 70 - Standard flags (bit-coded values):
      ;; 1  = Layer is frozen; otherwise layer is thawed
      ;; ...
      ;; 4  = Layer is locked
      ;; ...
      ;; 62 - Color number (if negative, layer is off)
      ;;
      ;; Or if your feeling adventrous you can combine frozen and locked
      ;; (1+4=5). something like...
      ;;
      ;; (setq laylst (entget (tblobjname "LAYER" "<YOUR LAYER NAME HERE>")))
      ;; (entmod
      ;;    (subst
      ;;       (cons 70 (boole 6 (cdr (assoc 70 laylst)) 5))
      ;;       (assoc 70 laylst)
      ;;       laylst))
      ;;

      (setq layer (tblobjname "LAYER" layername))
      (setq laylst (entget layer)
            props (cdr (assoc 70 laylst))
            off (cdr (assoc 62 laylst))
            freeze 1
            lock 4
            )

      (setq props (boole 6 props freeze))
      (setq off (1+ (~ off)))
      (setq props (boole 6 props lock))

      (setq laylst (subst (cons 70 props) (assoc 70 laylst) laylst)
            laylst (subst (cons 62 off) (assoc 62 laylst) laylst))

      (entmod laylst)
      )


    (defun change_circ ()
      (setq ss (ssget "x" '((0 . "CIRCLE"))))
      (setq
        elist (entget (ssname ss 0))
        alter (subst (cons 40 (1+ (cdr (assoc 40 elist)))) (assoc 40 elist) elist))
      (entmod alter)
      )

    (defun draw_circ ( )
      (command "circle")
      (while (eq (logand 1 (getvar "CMDACTIVE")) 1)
             (COMMAND PAUSE)))

    ;; end support procedures


    ;; do some stuff
    (tog_layer_stuff "0")
    (draw_circ)
    (change_circ)
    (tog_layer_stuff "0")

    (command "change" "all" "" "p" "color" "251" "")

    )
 )

Daron
Toy around with this some more -e.g. move tog_layer_stuff up in the list and see what happens.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

daron

  • Guest
Re: Reverse Layers
« Reply #19 on: February 06, 2008, 04:55:36 PM »
A'right, another day though. I need to get something finished up here and get out of here. See you tomorrow.

daron

  • Guest
Re: Reverse Layers
« Reply #20 on: February 07, 2008, 09:14:59 AM »
That is so crazy. You still have to thaw the layer to be able to make changes. It still bugs me that you have to make a physical change to it to make the objects visible. i.e. (command "change" "all" "" "p" "color" "251" "")

JohnK

  • Administrator
  • Seagull
  • Posts: 10638
Re: Reverse Layers
« Reply #21 on: February 07, 2008, 10:07:58 AM »
Yeah that part confused me too. But i had fun toying with the thought.

...I wonder what a redraw will do?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org