Author Topic: Trying to Thaw layers using ENTUPDATE  (Read 3298 times)

0 Members and 1 Guest are viewing this topic.

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Trying to Thaw layers using ENTUPDATE
« on: October 22, 2010, 03:34:39 AM »
And it's not entirely working.  There are two main routines:
LISO isolates layers on an hardcoded list and works perfectly.
LUSO is suppose to put things back the way they were.  All of the layer dialogue boxes and so worth update to show the layers thawed but the layers' contents aren't visible on screen (until you isolate and unisolate one of the previously-thawed layers).

My code is attached, I would greatly appreciate it if somebody could have a look for me - I'm sure it's something terribly obvious!

dJE
===
dJE

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Trying to Thaw layers using ENTUPDATE
« Reply #1 on: October 22, 2010, 08:19:43 AM »
I'm off and running this morning so no time until this afternoon late.
So here is some food for thought. 8-)

-------------   Isolate Layer   -------------------
http://www.theswamp.org/index.php?topic=30392.0 Isolate object  by Tim Willey
http://www.theswamp.org/index.php?topic=30142.0 Isolate nested layers  by RonJonp
http://www.theswamp.org/index.php?topic=9131.msg117714#msg117714  by CAB
http://www.theswamp.org/index.php?topic=34490.0 by John
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ScottBolton

  • Guest
Re: Trying to Thaw layers using ENTUPDATE
« Reply #2 on: October 22, 2010, 10:18:10 AM »
Daniel,

I'm pretty sure for thawing layers you'll need a regen: (vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acAllViewports)

S

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Trying to Thaw layers using ENTUPDATE
« Reply #3 on: October 22, 2010, 01:40:31 PM »
Daniel,

I'm pretty sure for thawing layers you'll need a regen: (vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acAllViewports)

S
I've had situations where even regen won't do it. You can trying setting each layer as current, selecting everything, selecting everything and invoking MOVE on the objects or even swapping from model to paper and back (horrible).
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ScottBolton

  • Guest
Re: Trying to Thaw layers using ENTUPDATE
« Reply #4 on: October 25, 2010, 01:52:49 AM »
Horrid! I've fortunately not had any of those situations. Time to upgrade to 2011!!

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: Trying to Thaw layers using ENTUPDATE
« Reply #5 on: October 27, 2010, 03:46:47 AM »
CAB, thanks for these.  Unfortunately they all seem to work by turning layers off, rather than freezing them, as my routine is trying to do.  Additionally they all seem to use VL, rather than AL which I'm trying to keep to.

dJE

I'm off and running this morning so no time until this afternoon late.
So here is some food for thought. 8-)

-------------   Isolate Layer   -------------------
http://www.theswamp.org/index.php?topic=30392.0 Isolate object  by Tim Willey
http://www.theswamp.org/index.php?topic=30142.0 Isolate nested layers  by RonJonp
http://www.theswamp.org/index.php?topic=9131.msg117714#msg117714  by CAB
http://www.theswamp.org/index.php?topic=34490.0 by John
===
dJE

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: Trying to Thaw layers using ENTUPDATE
« Reply #6 on: October 27, 2010, 03:50:49 AM »
Thanks for the sugggestion, Scott, but unfortunately this doesn't work!

As Alan pointed up a Regen command doesn't work in this situation, so I wasn't expecting a code version to do so (I assure you I did try it, though).  Currently I've put
Code: [Select]
(COMMAND "MOVE" "ALL" "" "0,0" "0,0") as a final line of code, but obviously aren't keen on this.

dJE

Daniel,

I'm pretty sure for thawing layers you'll need a regen: (vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acAllViewports)

S
===
dJE

ScottBolton

  • Guest
Re: Trying to Thaw layers using ENTUPDATE
« Reply #7 on: October 27, 2010, 04:08:19 AM »
WOMPC@W (works on my PC at work!).

Sorry I can't offer anything else. Maybe post a drawing and I could have a ganders? If I remember rightly, there's a couple of functions missing in your OP. Maybe include them as well?

S

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Trying to Thaw layers using ENTUPDATE
« Reply #8 on: October 27, 2010, 08:25:04 AM »
Look at this one.
Code: [Select]
;;  by sMadsen ?
;;With one argument for all options (except color).

;; bitcodes:          *
;;  0 = nothing       *
;;  1 = layer off     *
;;  2 = layer freeze  *
;;  4 = layer on      *
;;  8 = layer thaw    *
;; 16 = plot on       *
;; 32 = plot off      *
;; 64 = current
(defun setlayerstatus (clayer status /   blist    lbits
       lcol lent lentl   lplot    tmp
       findbits substitute
      )
  (defun findbits (num / a bitlist)
    (setq a 1)
    (while (>= num a)
      (and (= (logand num a) a) (setq bitlist (cons a bitlist)))
      (setq a (lsh a 1))
    )
    (reverse bitlist)
  )
  (defun substitute (elist code value)
    (subst (cons code value) (assoc code elist) elist)
  )
  (cond
    ((and (= (type clayer) 'str)
  (setq lent (tblobjname "LAYER" clayer))
     )
     (setq lentl (entget lent)
   lbits (cdr (assoc 70 lentl))
   lcol (cdr (assoc 62 lentl))
   lplot (cdr (assoc 290 lentl))
   blist '((1 62 (- lcol))
   (2 70 (logior lbits 1))
   (4 62 (abs lcol))
   (8 70 (boole 2 lbits 1))
   (16 290 1)
   (32 290 0)
  )
     )
     (foreach bit (findbits status)
       (and (setq tmp (cdr (assoc bit blist)))
    (setq lentl (substitute lentl (car tmp) (eval (cadr tmp))))
       )
     )
     (and (= 64 (logand status 64)) (setvar "CLAYER" clayer))
    )
  )
  (entmod lentl)
)


;; bitcodes:          *
;;  0 = nothing       *
;;  1 = layer off     *
;;  2 = layer freeze  *
;;  4 = layer on      *
;;  8 = layer thaw    *
;; 16 = plot on       *
;; 32 = plot off      *
;; 64 = current
(defun c:test ()
  (defun stupdate (bit)
    (setq status (+ status bit))
  )

  (setq nlyr (getstring (prompt "\nName of New Layer :")))
  ;;(setq NCLR (getint "\nColor of New Layer (must be a number 1-255) :"))
  (initget 1 "Yes No")
  (if (= (getkword "\nShould this layer be On (Yes/No): ") "Yes")
    (stupdate 4)
    (stupdate 1)
  )
  (initget 1 "Yes No")
  (if (= (getkword "\nShould this layer be Thawed  (Yes/No): ") "Yes")
    (stupdate 8)
    (stupdate 2)
  )
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: Trying to Thaw layers using ENTUPDATE
« Reply #9 on: October 27, 2010, 09:03:15 AM »
OK, a real toughie!

What does <code>(2 70 (logior lbits 1))</code> do?  Is it setting a list to freeze the specified layer?  Except that logically (no pun intended) <code>(8 70 (boole 2 lbits 1))</code> would be thawing the same layer - OK, that's not what they're trying to to :(

You have a COND encompassing an entire AND statement, is that as an alternative to an IF?

The foreach loop seems to be using the list created earlier to update the layer definition.  Still comes down to an (ENTMOD lentl) the same as mine does, though <confused>.

dJE


Look at this one.
...
===
dJE

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Trying to Thaw layers using ENTUPDATE
« Reply #10 on: October 27, 2010, 09:17:30 AM »
Sorry Daniel I didn't look at your code.
I will this afternoon late, but now I'm off again.

The cond is like an IF in this case
The AND is verifying the layer name

Yes it comes back to ENTMOD.

Later.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: Trying to Thaw layers using ENTUPDATE
« Reply #11 on: November 03, 2010, 09:24:19 AM »
CAB, did you ever get chance to look at my code at all?

dJE

Sorry Daniel I didn't look at your code.
I will this afternoon late, but now I'm off again.

The cond is like an IF in this case
The AND is verifying the layer name

Yes it comes back to ENTMOD.

Later.
===
dJE

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Trying to Thaw layers using ENTUPDATE
« Reply #12 on: November 03, 2010, 06:48:48 PM »
Just did.
Can you post (LAYTBL)
I'm a little confused by you code.
How do you create the list of layers to freeze?

Leaving in the AM for a fishing trip so I may not have time to respond.


I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: Trying to Thaw layers using ENTUPDATE
« Reply #13 on: November 04, 2010, 04:17:12 AM »
Laytbl is below.  It scans the layer table a layer at a time.  If a layer is neither frozen (= 1 lays) nor in the list of layers to keep on (NOT (MEMBER layn lolist)) that layer is added to FREEZELIST, this is then used to freeze the layers.

dJE

Code: [Select]
(DEFUN laytbl ( / tdef layn lays laystate  );CREATES THREE LISTS: laylist CONTAINS ALL THE NON-XREF DEPENDANT LAYERS, freezelist LISTS THOSE THAT ARE TO BE FROZEN, AND laystatelist CONTAINS ALL NON-XREF DEPEDANT LAYERS WITH THEIR STATE AS A DOTTED PAIR
(LAYONLIST);CREATES ROOF HATCH AND ROOF HATCH OUTLINE LAYERS, IF NECESSARY.  GENERATE A LIST OF LAYERS TO KEEP THAWED
(SETQ
laylist nil;ENSURE laylist IS EMPTY
layc (GETVAR "CLAYER");STORE CURRENT LAYTER
);SETQ
(SETVAR "CLAYER" SetCurrentLayer)

(WHILE
(SETQ tdef (TBLNEXT "LAYER" (NOT tdef)));LOOP WHILE THE NEXT LAYER TABLE ENTRY IS NOT THE CURRENT ONE
(IF
(> 16 (LOGAND (CDR (ASSOC 70 tdef))));REMOVE XREF-DEPENDANT LAYERS
(PROGN;LEAP MULTIPLE EXPRESSIONS IN A SINGLE BOUND
(SETQ
layn (CDR (ASSOC 2 tdef));LAYER NAME
laylist (MERGELIST layn laylist);ADD LAYER TO LAYER LIST
lays (CDR (ASSOC 70 tdef));LAYER STATE
laystate (CONS layn lays);DOTTED PAIR OF LAYER NAME AND STATE
laystatelist (MERGELIST laystate laystatelist);DOTTED PAIR LIST
);SETQ
(IF
(NOT
(= 1 lays);IF LAYER IS NOT FROZEN
);NOT
(IF
(NOT
(MEMBER layn lolist);IF LAYNER IS NOT IN THE lolist LIST
);NOT
(SETQ freezelist (MERGELIST layn freezelist));ADD LAYER TO THE LIST OF LAYERS TO BE FROZEN
);IF
);IF
);PROGN
);IF NOT XREF-DEPENDANT
);WHILE

(PRINC);CLEAN EXIT
);DEFUN

Just did.
Can you post (LAYTBL)
I'm a little confused by you code.
How do you create the list of layers to freeze?

Leaving in the AM for a fishing trip so I may not have time to respond.



===
dJE