Strange behavior thawning layers with entmod.

Strange behavior thawning layers with entmod.

Anonymous
Not applicable
960 Views
5 Replies
Message 1 of 6

Strange behavior thawning layers with entmod.

Anonymous
Not applicable

Hello everybody,

 

In some of my functions evolving layouts I had to create a way of freezing all layers so  AutoCad runned more smoothly.

The following two functions i use in the beginning and ending of other routines so they run faster but I'm having a very strange behavior:

 

(defun freezeall ()

  (setq cLay(tblnext "LAYER" T))
  (setq listagemparavoltar nil)
  (while cLay
    (if (= (cdr(assoc 2 cLay)) (getvar "CLAYER")) ;;;Is cLay Current Layer?;;;;
      (setq cLay(tblnext "LAYER")) ;;;If true;;;;
      (progn  ;;;If false start;;;;
	(SETQ listagemparavoltar 
          (cons 
            (list
              (assoc 2 cLay)
              (assoc 70
                (entget (tblobjname "LAYER" (cdr(assoc 2 cLay))))))
          listagemparavoltar))
	(entmod
	  (SUBST
	    (CONS 70 1)
	    (assoc 70 (entget (tblobjname "LAYER" (cdr(assoc 2 cLay)))))
	    (entget (tblobjname "LAYER" (cdr(assoc 2 cLay))))
	  )
        )
	(setq cLay(tblnext "LAYER"))
      ) ;;;If false end;;;;
    ) ;;;End If;;;;
  ) ;;;End while;;;;
  
)

 

 

(defun thawlayers ()
  (foreach n listagemparavoltar
    (if (= (type n) 'list)
      (entmod
	(SUBST
	  (Car (cdr n))
	  (assoc 70 (entget (tblobjname "LAYER" (cdr (car n)))))
	  (entget (tblobjname "LAYER" (cdr (car n))))
	)
      )
      
    )
  )
)

 

 It happens that the layers remain occult and they only reappear if I do "regenall" (manually, I tried doing it on Lisp but doest seem to have efect) on every layout, including modelspace.

 

Tank you very much for your help.

Marcos.

 

0 Likes
Accepted solutions (1)
961 Views
5 Replies
Replies (5)
Message 2 of 6

dbroad
Mentor
Mentor

Aside from regenmode perhaps being off, I don't see anything that would give you problems.  (Disclaimer:  Didn't look too closely).  How does your code work effectively different from this though?  Seems like a lot of work to avoid a command call.

(defun freezeall (/ *error*)
 ;null error routine
  (command "._-layer" "_freeze" "*" "")
)
(defun thawlayers (/ *error*)
 ;null error routine
  (command "._-layer" "_thaw" "*" "")
) 

 

Architect, Registered NC, VA, SC, & GA.
Message 3 of 6

Anonymous
Not applicable
Thanks Professor for your quick reply,

I find "entmod" a better way of dealing with properties changing because it:

1) Will work with undo;
2) Wont fill the command history with lots of Layer commands;
3) Also (in my opinion) it runs quicker if you are working with big dwgs.

Anyways I'll try using (command "._-layer") inside foreach to see what happens.

Marcos.
0 Likes
Message 4 of 6

Anonymous
Not applicable
Accepted solution

I've changed the Thawlayers function:

(defun thawlayers()

  (foreach n listagemparavoltar
    (if (= (type n) 'list)
      (progn
	(if (= (cdr (car (cdr n))) 0)
	  (command "._-layer" "_thaw" (cdr (car n)) ""))))
  )

)

Now it is working without having to Regenall.

 

 

P.S. I use the list "listagemparavoltar" because I want this function to thaw only the layers that were already thawed before the "Freezeall" function.

 

Marcos.

0 Likes
Message 5 of 6

_Tharwat
Advisor
Advisor
A bit modification on your codes if you would like to:
  (foreach n listagemparavoltar
    (if (and (= (type n) 'list)
(= (cdr (car (cdr n))) 0)
)
(command "._-layer" "_thaw" (cdr (car n)) "")) )
@Anonymous wrote:

 

(defun thawlayers()

  (foreach n listagemparavoltar
    (if (= (type n) 'list)
      (progn
	(if (= (cdr (car (cdr n))) 0)
	  (command "._-layer" "_thaw" (cdr (car n)) ""))))
  )

)

 


 

Message 6 of 6

dbroad
Mentor
Mentor

Glad to help and glad you got your fix.  Be sure to mark your modification as a solution if it fits your needs.

Architect, Registered NC, VA, SC, & GA.