Jump to content

Recommended Posts

Posted

Hi,

 

I am looking to lock multiple layers simultaneously by selection window. Or by clicking multiple times. The inbuilt lock layer (_laylck) command does not seem to support selection windows and only does one layer at a time. I would like to do mutiples. I am fairly new to LISP but fairly good at script writing (been on LT for several year, now on full!!!)

 

I found this script on the forum;

 

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))                         

Though autocad (2011) throws out an error (see below)

 

Select object: ; error: no function definition: ENGET
Any suggestions on how to modify the above

a) to work and

b) to do what i want?

 

Or is there a better way?

 

Thanks for your help!

Posted

your 'title' needs a semicolon at the beginning to be ignored by lisp

but that didn't solve it

 

edit:

there is a syntax error somewhere as it doesn't load properly

but i am not the one to say where......

someone will come along who can help soon!

Posted

There is an error because the function 'enget' should be 'entget' in your code.

 

I would approach it this way:

 

(defun c:lck ( / b e i l s x )
 
 (if (setq s (ssget))
   (repeat (setq i (sslength s))
     (if (not (member (setq l (cdr (assoc 8 (entget (ssname s (setq i (1- i))))))) x))
       (progn
         (setq e (entget (tblobjname "LAYER" l))
               x (cons l x)
               b (cdr (assoc 70 e))
         )
         (entmod (subst (cons 70 (logior 4 b)) (assoc 70 e) e))
       )
     )
   )
 )
 (princ)
)

I'm confused in that your thread speaks of locking layers, but the code you present is freezing them - which is it?

Posted

also, there are 12 "(" and 14 ")" which is not a good sign. has this code been hashed somewhere along the line? i tired to fix it, but fixed the syntax and then the error was a dodgy list.

 

as i said...... a qualified lisper will be along shortly........

Posted

lee i tried entget but still it wouldn't work.... is the code just badly done?

Posted
lee i tried entget but still it wouldn't work.... is the code just badly done?

 

That was the first thing I noticed, but yes, the code is littered with mistakes.

 

A quick rewrite to get it working:

 

(defun c:frz ( / e )
 (if (setq e (car (entsel)))
   (command "_.-layer" "_freeze" (cdr (assoc 8 (entget e))) "")
 )
 (princ)
)

Posted (edited)
That was the first thing I noticed, but yes, the code is littered with mistakes.

 

A quick rewrite to get it working:

 

(defun c:frz ( / e )
 (if (setq e (car (entsel)))
   (command "_.-layer" "_freeze" (cdr (assoc 8 (entget e))) "")
 )
 (princ)
)

 

._LAYFRZ ...? :lol:

 

Edit: And for the thread title ._LAYLCK

Edited by BlackBox
Posted

azn.gif

Command: LA
-LAYER
Current layer:  "C-PIPE"
Enter an option 
[?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Fre
eze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: LOCK

Enter name list of layer(s) to lock or <select objects>:

Select objects: Specify opposite corner: 6 found

Posted

lol - looks like all the code in this thread is redundant :lol:

 

Oh well, I enjoyed writing it :)

Posted
lol - looks like all the code in this thread is redundant :lol:

 

Oh well, I enjoyed writing it :)

What was really nice was in the the pre 2009 versions, you could use a macro or LISP macro to select the property wanted (freeze, thaw, etc.) and then enter once to select (as it does in the core), but the 09 and on seemed to have screwed that up and it just goes back to the layer menu.

 

Here's some of the first macros I ever wrote:

;ALLOWS YOU TO FREEZE BY ENTERING IN LAYER NAMES (WILD CARDS ALLOWED)
(defun c:LAZ ()
(command "-layer" "freeze" )
(princ))


;ALLOWS YOU TO TURN OFF LAYERS BY ENTERING IN LAYER NAMES (WILD CARDS ALLOWED)
(defun c:LAF ()
(command "-layer" "off" )
(princ))


;LOCK LAYER(S) BY PICK OR BY NAME (WILD CARDS ALLOWED)
(defun c:LK ()
(command "-layer" "lock" )
(princ))

;UNLOCK LAYER(S) BY PICK OR BY NAME (WILD CARDS ALLOWED)
(defun c:LU ()
(command "-layer" "unlock" )
(princ))

 

You could type in the layer filter or enter/right-click once and select away.

Posted
[ATTACH]26988[/ATTACH]

-LAYER

 

AH I hadn't even thought about running the command line option! Duh!

 

I can write a button macro to get through to that point and quickly lock several layers at once again.

 

lol - looks like all the code in this thread is redundant :lol:

 

Oh well, I enjoyed writing it :)

 

I enjoyed reading it. Beginning to understand how LISP works now!

 

Thanks guys!

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...