Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

If layer is frozen

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
F.Camargo
572 Views, 5 Replies

If layer is frozen

Hi guys,

How Can I add a routine to verify if the layer ( AREA-TEMP) were frozen, it will thaw it?

 

code bellow:

(defun c:BOU (/ pt)
  ;; save current layer in the variable "clr"
  (setq clr (getvar "clayer"))
  ; create (if not exist) and set layer "cotas-perfil" current
    (command "_layer" "m" "AREA-TEMP" "c" "1" "" "s" "AREA-TEMP" "")
  (while (setq pt (getpoint "\nPick internal point: "))
    (command "_.-boundary" "_a" "_i" "_n" "" "" "_non" pt "")
  )
  (setvar "clayer" clr);<-- always restore layer at the end of code
  (princ)
)

 thank in advance

5 REPLIES 5
Message 2 of 6
hmsilva
in reply to: F.Camargo

Something like this perhaps

 

(defun c:BOU (/ clr lay pt)
  ;; save current layer in the variable "clr"
  (setq clr (getvar "clayer"))
  ; create (if not exist) and set layer "cotas-perfil" current
  (setq lay (tblsearch "LAYER" "AREA-TEMP"))
  (if (null lay)
    (command "_layer" "m" "AREA-TEMP" "c" "1" "" "s" "AREA-TEMP" "")
    (if	(= (logand 1 (cdr (assoc 70 lay))) 1)
      (command "_layer" "t" "AREA-TEMP" "s" "AREA-TEMP" "")
      (command "_layer" "s" "AREA-TEMP" "")
    );; if
  );; if
  (while (setq pt (getpoint "\nPick internal point: "))
    (command "_.-boundary" "_a" "_i" "_n" "" "" "_non" pt "")
  )
  (setvar "clayer" clr);<-- always restore layer at the end of code
  (princ)
)

 

HTH

Henrique

EESignature

Message 3 of 6
F.Camargo
in reply to: hmsilva

Wow

Thank you hmsilva!!!!

 

Thank for the very quick replay and the fantastic solution!!

 

Best Regards Smiley Happy

 

 

Message 4 of 6
hmsilva
in reply to: F.Camargo

You're welcome, F.Camargo
Glad I could help

 

Henrique

EESignature

Message 5 of 6
Kent1Cooper
in reply to: F.Camargo


@F.Camargo wrote:

Hi guys,

How Can I add a routine to verify if the layer ( AREA-TEMP) were frozen, it will thaw it?

....


A simpler way is to not bother checking whether it's frozen, but simply thaw it regardless, before making it.  It has to be before making it, because if it already exists and is frozen, the Make option will fail, since it can't make a frozen Layer current.  If it doesn't exist yet, it won't matter -- a message will go by that it didn't find it to thaw, but it will continue anyway, and make the Layer.  And using the Make option, you don't need that Set option you had in there -- that's part of what the Make option does.

....

  ; create (if not exist) and set layer "cotas-perfil" current
    (command "_layer" "t" "AREA-TEMP" "m" "AREA-TEMP" "c" "1" "" "")
  (while ....

Kent Cooper, AIA
Message 6 of 6
F.Camargo
in reply to: Kent1Cooper

Hi,
Thank you very much, Kent.
The code worked too.

I've learnt good tings with both of you guys!
Thank you hmsilva and Kent!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost