Author Topic: Unfrozen a list of layers  (Read 4981 times)

0 Members and 1 Guest are viewing this topic.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Unfrozen a list of layers
« on: March 20, 2012, 08:39:05 AM »
Hello .

Here is my code that would unfrozen a list of layers , but the issue is that the code does the trick and the entities being hidden for a while until
I jump to any layout and go back to model to allow objects to be appeared , and the command *regen* or *regenall* did not solve the issue .

Is there anything goes wrong within my code ?

Code: [Select]
  (defun Unfrozen-Layers (Layerlist / tbl)
    ;;; Tharwat 20. march. 2012 ;;;
    (foreach x Layerlist
      (if (tblsearch "LAYER" x)
        (entmod
          (subst (cons 70 0)
                 (assoc 70 (setq tbl (entget (tblobjname "LAYER" x))))
                 tbl
          )
        )
      )
    )
    (princ)
  )

Thank you

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Unfrozen a list of layers
« Reply #1 on: March 20, 2012, 03:50:11 PM »
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.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Unfrozen a list of layers
« Reply #2 on: March 20, 2012, 03:57:01 PM »
Thank you CAB .

I know how to make it in VLisp , but I am looking for Vanilla codes , although I can not see any error of my previous code and I need someone to test the code and tell me if they may have the same result that I had .

Appreciated a lot.


danallen

  • Guest
Re: Unfrozen a list of layers
« Reply #3 on: March 20, 2012, 07:00:16 PM »
do you need to entupd the modified table? my vanilla version just uses command calls

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Unfrozen a list of layers
« Reply #4 on: March 20, 2012, 07:08:00 PM »
Tested your code in plain 2006 and same problem.
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.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Unfrozen a list of layers
« Reply #5 on: March 20, 2012, 11:32:00 PM »
Make a selection set of the items and (redraw <entity> 1) each.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Unfrozen a list of layers
« Reply #6 on: March 21, 2012, 02:45:15 AM »
Make a selection set of the items and (redraw <entity> 1) each.

The same thing , although that the selection set is not nil which means that it selects the unfrozen entities during the routine but it doesn't show them . :-(

Any other idea ?  :-)

Thanks

Code: [Select]
(defun Unfrozen-Layers (Layerlist / tbl ents i)
;;; Tharwat 20. march. 2012 ;;;
  (foreach x Layerlist
    (if (tblsearch "LAYER" x)
      (progn
        (entmod
          (subst (cons 70 0)
                 (assoc 70 (setq tbl (entget (tblobjname "LAYER" x))))
                 tbl
          )
        )
        (if (setq ents (ssget "_x" (list (cons 8 x))))
          (repeat (setq i (sslength ents))
            (redraw (ssname ents (setq i (1- i))) 1)
          )
        )
      )
    )
  )
  (princ)
)


Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: Unfrozen a list of layers
« Reply #7 on: March 21, 2012, 03:24:56 AM »
Try
Code: [Select]
(setvar 'LAYLOCKFADECTL 0)before unlocking layers, then set it back to original value.

[edit] Forget it.... I was thinking to Unlock Layers..

[Edit 2]:
replace
Code: [Select]
(redraw (ssname ents (setq i (1- i))) 1)with
Code: [Select]
(entupd (ssname ents (setq i (1- i))))
« Last Edit: March 21, 2012, 04:02:02 AM by Stefan »

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Unfrozen a list of layers
« Reply #8 on: March 21, 2012, 07:13:06 AM »
Try
Code: [Select]
(setvar 'LAYLOCKFADECTL 0)before unlocking layers, then set it back to original value.

[edit] Forget it.... I was thinking to Unlock Layers..

[Edit 2]:
replace
Code: [Select]
(redraw (ssname ents (setq i (1- i))) 1)with
Code: [Select]
(entupd (ssname ents (setq i (1- i))))

Great work Stefan .  :-)

Thank you so much .

ronjonp

  • Needs a day job
  • Posts: 7531
Re: Unfrozen a list of layers
« Reply #9 on: March 21, 2012, 10:11:50 AM »
Not sure if you need it, but I added a line to turn the layer on as well:

Code - Auto/Visual Lisp: [Select]
  1. (defun unfrozen-layers (layerlist / ents i l)
  2. ;;; Tharwat 20. march. 2012 ;;;
  3.   (foreach x layerlist
  4.     (if (setq l (tblobjname "LAYER" x))
  5.       (progn
  6.         (entmod (subst '(70 . 0) (assoc 70 (entget l)) (entget l)))
  7.         ;; This line turns the layer on
  8.         (entmod (subst (cons 62 (abs (cdr (assoc 62 (entget l))))) (assoc 62 (entget l)) (entget l))
  9.         )
  10.         (if (setq ents (ssget "_x" (list (cons 8 x))))
  11.           (repeat (setq i (sslength ents)) (entupd (ssname ents (setq i (1- i)))))
  12.         )
  13.       )
  14.     )
  15.   )
  16.   (princ)
  17. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Unfrozen a list of layers
« Reply #10 on: March 21, 2012, 02:53:40 PM »
BTW, if the layer is locked, it will be unlocked by just putting 0 to the 70 dxf code.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

lamarn

  • Swamp Rat
  • Posts: 636
Re: Unfrozen a list of layers
« Reply #11 on: July 02, 2014, 03:37:47 PM »
I use a routine that sums a list of frozen layers.
I would like to use the same code to list vp frozen layer.
What is wright code i shoul use for 'lyr'. Could use some help. thanks

Code: [Select]

(defun C:THL (/ oldEcho lyr lyrList dh rtnList)
     (setq
       oldEcho (getvar "cmdecho")
       lyr (tblnext "layer" 'T)
     )
     (while lyr
       (if (not (zerop (logand (cdr (assoc 70 lyr)) 4)))  ;<- ASSOC 70 LYR
          (setq lyrList (cons (cdr (assoc 2 lyr)) lyrList))
       )
       (setq lyr (tblnext "layer"))
     )
     (if lyrList
       (progn
         (if (< (length lyrList) (getvar "maxsort"))
           (setq lyrList (acad_strlsort lyrList))
         )
         (setq dh (load_dialog "ddthaw.dcl"))
         (if (not (new_dialog "ddlocked" dh))(exit))
         (start_list "lyrlist")
         (mapcar 'add_list lyrList)
         (end_list)
         (action_tile "lyrlist" "(setq rtnList $value)")
         (action_tile "cancel" "(done_dialog 0)")
         (action_tile "accept" "(done_dialog 1)")
         (if (= (start_dialog) 1)
           (progn
             (setq rtnList (read (strcat "(" rtnList ")")))
             (command "_.layer")
             (foreach i rtnList
               (command "unlock" (nth i lyrList))
             )
             (command "")
           )
         )
         (unload_dialog dh)
       )
       (alert "Drawing does not contain\n   any locked layers!\n")
     )
     (princ)
   )


Design is something you should do with both hands. My 2d hand , my 3d hand ..

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Unfrozen a list of layers
« Reply #12 on: July 02, 2014, 04:05:56 PM »
Take a look at this:
Code: [Select]
(defun LayerFrozenList(doc / result)
  (vlax-for layer (vla-get-Layers doc)
    (if (= (vla-get-freeze layer) :vlax-true)
      (setq result (cons (vla-get-name layer) result)))
    )
  result
)

(setq lst (LayerFrozenList (vla-get-ActiveDocument (vlax-get-acad-object))))
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.

lamarn

  • Swamp Rat
  • Posts: 636
Re: Unfrozen a list of layers
« Reply #13 on: July 02, 2014, 04:20:13 PM »
So, this might work you think..(?)
====

(defun C:THL (/ oldEcho lyr lyrList dh rtnList)
     (setq
       oldEcho (getvar "cmdecho")
;;;
  (vlax-for layer (vla-get-Layers doc)
    (if (= (vla-get-freeze layer) :vlax-true)
      (setq result (cons (vla-get-name layer) result)))
    )
  result
)

(setq lst (LayerFrozenList (vla-get-ActiveDocument (vlax-get-acad-object))))
;;;;
     (if LayerFrozenList
       (progn
         (if (< (length LayerFrozenList) (getvar "maxsort"))
           (setq lyrList (acad_strlsort lyrList))
         )

....;; etc.
Design is something you should do with both hands. My 2d hand , my 3d hand ..

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Unfrozen a list of layers
« Reply #14 on: July 02, 2014, 04:35:27 PM »
Looks promising.  8)
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.

lamarn

  • Swamp Rat
  • Posts: 636
Re: Unfrozen a list of layers
« Reply #15 on: July 02, 2014, 04:36:17 PM »
Thank you mr. CAB!
Design is something you should do with both hands. My 2d hand , my 3d hand ..

lamarn

  • Swamp Rat
  • Posts: 636
Re: Unfrozen a list of layers
« Reply #16 on: July 08, 2014, 05:13:29 PM »
Can you help with a few lines to get it to work..

Code: [Select]
(defun C:THV (/ doc result oldEcho lyr LayerFrozenList dh rtnList)
  (setq oldEcho (getvar "cmdecho")
  (vlax-for layer (vla-get-Layers doc)
    (if (= (vla-get-freeze layer) :vlax-true)
      (setq result (cons (vla-get-name layer) result)))
    )
  result
)

(setq lst (LayerFrozenList (vla-get-ActiveDocument (vlax-get-acad-object))))
     (if LayerFrozenList
       (progn
         (if (< (length LayerFrozenList) (getvar "maxsort"))
           (setq lyrList (acad_strlsort lyrList))
         )

         (setq dh (load_dialog "ddthaw.dcl"))
         (if (not (new_dialog "ddthaw" dh))(exit))
         (start_list "lyrlist")
         (mapcar 'add_list LayerFrozenList)
         (end_list)
         (action_tile "lyrlist" "(setq rtnList $value)")
         (action_tile "cancel" "(done_dialog 0)")
         (action_tile "accept" "(done_dialog 1)")
         (if (= (start_dialog) 1)
           (progn
             (setq rtnList (read (strcat "(" rtnList ")")))
             (command "_.layer")
             (foreach i rtnList
               (command "thaw" (nth i LayerFrozenList))
             )
             (command "")
           )
         )
         (unload_dialog dh)
       )
       (alert "Viewport does not contain\n   any vp frozen layers!\n")
     )
     (princ)
)
Design is something you should do with both hands. My 2d hand , my 3d hand ..

hanhphuc

  • Newt
  • Posts: 64
Re: Unfrozen a list of layers
« Reply #17 on: July 09, 2014, 03:50:16 AM »
Just had a quick fixed. not perfect yet
1. add in, (vl-load-com) & doc
2. setq lst instead of setq LayerFrozenList
3. (setq oldEcho (getvar "cmdecho") ..; parenthesis not close
4. (if lst; instead of  (if LayerFrozenList..
5.  (and (= (start_dialog) 1) rtnList)
reset oldEcho
etc..

Code: [Select]
(defun C:THV (/ doc result oldEcho lyr LayerFrozenList dh rtnList)
 
  (defun unfrozen-layers (layerlist / ents i l)
;;; Tharwat 20. march. 2012 ;;;
  (foreach x layerlist
    (if (setq l (tblobjname "LAYER" x))
      (progn
(entmod (subst '(70 . 0) (assoc 70 (entget l)) (entget l)))
;; This line turns the layer on
(entmod (subst (cons 62 (abs (cdr (assoc 62 (entget l))))) (assoc 62 (entget l)) (entget l))
)
(if (setq ents (ssget "_x" (list (cons 8 x))))
  (repeat (setq i (sslength ents)) (entupd (ssname ents (setq i (1- i)))))
)
      )
    )
  )
  (princ)
)

(defun LayerFrozenList(doc / result)
  (vlax-for layer (vla-get-Layers doc)
    (if (= (vla-get-freeze layer) :vlax-true)
      (setq result (cons (vla-get-name layer) result)))
    )
  result
)


(setq doc     (vla-get-activedocument (vlax-get-acad-object))
      oldEcho (getvar "cmdecho")
      lst     (LayerFrozenList doc)
      ) ;_ end of setq
 (setvar "cmdecho" 0)
     (if lst; LayerFrozenList
       (progn
         (if (< (length lst) (getvar "maxsort"))
           (setq lyrList (acad_strlsort lyrList))
         )

         (setq dh (load_dialog "ddthaw.dcl"))
         (if (not (new_dialog "ddthaw" dh))(exit))
         (start_list "lyrlist")
         (mapcar 'add_list lst)
         (end_list)
         (action_tile "lyrlist" "(setq rtnList $value)")
         (action_tile "cancel" "(done_dialog 0)")
         (action_tile "accept" "(done_dialog 1)")
         (if (and (= (start_dialog) 1) rtnList)
           (progn
             (setq rtnList (read (strcat "(" rtnList ")")))
             (command "_.layer")
             (foreach i rtnList
               (command "thaw" (nth i lst))
             )
             (command "")
           )
         )
         (unload_dialog dh)
       )
       (alert "Viewport does not contain\n   any vp frozen layers!\n")
     )

    (setvar "cmdecho" oldEcho)
     (princ)
)
(vl-load-com)
( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" ) ; error: too many arguments

lamarn

  • Swamp Rat
  • Posts: 636
Re: Unfrozen a list of layers
« Reply #18 on: July 09, 2014, 03:21:09 PM »
Thanks for your reply!

instead of using (vla-get-freeze ... i need the vp equevalent... something lik (vla-get-vpfreeze..
I dont know. vpfreeze does not exist. i has tp be something else.
Design is something you should do with both hands. My 2d hand , my 3d hand ..