Jump to content

Recommended Posts

Posted

hi,

how to lock/freeze the layer through lisp

 

regards

m.arunachalam

Posted

Here are a couple of ways.

 

(command "._LAYER" "_LO" "0" "")

(vla-put-lock
 (vla-item (vla-get-layers
             (vla-get-activedocument (vlax-get-acad-object))
           )
           "0"
 )
 :vlax-true
)

Posted

Here is another play toy.

 

;;  layerSet.lsp  by CAB  07/19/2006
;;  Set layer state
;;
;;  Arguments - <layer name> <state to set>
;;  States supported
;;  On
;;  Off
;;  Freeze
;;  Thaw
;;  Lock
;;  Unlock
;;  Plot
;;  Noplot

(defun layerset (lname state / sym mode)
 (if (and (setq obj (tblobjname "layer" lname))
          (setq obj (vlax-ename->vla-object obj)))
   (progn
     (cond
       ((= "ON" (setq state (strcase state)))
        (setq sym  'vla-put-layeron mode :vlax-true))
       ((= "OFF" state)
        (setq sym  'vla-put-layeron mode :vlax-false))
       ((= "FREEZE" state)
        (setq sym  'vla-put-freeze mode :vlax-true))
       ((= "THAW" state)
        (setq sym  'vla-put-freeze mode :vlax-false))
       ((= "LOCK" state)
        (setq sym  'vla-put-lock mode :vlax-true))
       ((= "UNLOCK" state)
        (setq sym  'vla-put-lock mode :vlax-false))
       ((= "PLOT" state)
        (setq sym  'vla-put-plottable mode :vlax-true))        
       ((= "NOPLOT" state)
        (setq sym  'vla-put-plottable mode :vlax-false))
     )
     (if mode
       (not (vl-catch-all-error-p (vl-catch-all-apply sym (list obj mode))))
     )
   )
 )
)

(defun c:test(/ ent ln)
 (and
   (setq ent (car(entsel "\nSelect an object to turn layer off")))
   (or (layerset (setq ln (cdr (assoc 8 (entget ent)))) "")
       (not (prompt (strcat "\nLayer " ln " was turnes OFF."))))
   (prompt (strcat "\nCould not turn layer " ln " OFF."))
 )
)

  • 2 years later...
Posted

i need a program that will allow you to pick the objects from the screen and then ask the user to give a name for the new layer state.

  • 1 year later...
Posted
hi,

how to lock/freeze the layer through lisp

 

regards

m.arunachalam

 

(defun c:lock ()

(setvar "cmdecho" 0)

(setq data (enget (car (entsel)))))

(setq laynme assoc 8 data))

(setq lay (cdr laynme))

(command "layer" "lock" lay "")

(princ)):D

Posted

type "frz" to run lisp

((defun c:frz ()

(setvar "cmdecho" 0)

(setq data (enget (car (entsel)))))

(setq laynme assoc 8 data))

(setq lay (cdr laynme))

(command "layer" "freeze" lay "")

(princ))

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...