Jump to content

Recommended Posts

Posted

Hi i want to have a lisp that will freeze layer batters in the drawing batters but i don't want it to do it any where else. even if i run the lisp

Heres what iv got so far

(setq dn (getvar 'DWGNAME))
(if (= dn "batters.dwg")
(command "-layers" "F" "BATTERS")
);if

this won't work what am i doing wrong.

Posted

(command "-layer"........... not "-layers"

Posted

The use of command is going to be slower than ent* or vla, but it's more than sufficient.

For command usage, here's what I'd do...

 

(if (and (eq (strcase (getvar 'DWGNAME)) "BATTERS.DWG") ;capitalize to ignore case
        (tblsearch "LAYER" "BATTERS") ;check if layer exists (not really necessary)
   )
 (if (eq (strcase (getvar 'CLAYER)) "BATTERS") ;check if current layer is "BATTERS"
   (command "_.-layer" "_T" "0" "_S" "0" "_F" "BATTERS" "") ; if so, thaw/set 0 as current and freeze layer
   (command "_.-layer" "_F" "BATTERS" "") ; freeze layer
 )
)

Posted

Codes and not command call . :D

 

(if (and (eq (strcase (getvar 'DWGNAME)) "BATTERS.DWG")
        (tblsearch "LAYER" "BATTERS")
        )
 (progn
   (setq l (entget (tblobjname "LAYER" "BATTERS")))
   (entmod (subst (cons 70 1) (assoc 70 l) l))
   )
 )

 

Tharwat

Posted
Codes and not command call . :D

 

(if (and (eq (strcase (getvar 'DWGNAME)) "BATTERS.DWG")
        (tblsearch "LAYER" "BATTERS")
        )
 (progn
   (setq l (entget (tblobjname "LAYER" "BATTERS")))
   (entmod (subst (cons 70 1) (assoc 70 l) l))
   )
 )

Tharwat

I hope the layer isn't locked, current, etc.

You might benefit from reading about the additional properties stored in dxf 70 for layers. :roll:

Posted
I hope the layer isn't locked, current, etc.

You might benefit from reading about the additional properties stored in dxf 70 for layers. :roll:

 

1+

 

Read up on the use of such functions as logand / logior / boole etc.

 

 

Posted
I hope the layer isn't locked, current, etc.

You might benefit from reading about the additional properties stored in dxf 70 for layers. :roll:

 

1+

 

Read up on the use of such functions as logand / logior / boole etc.

 

This is two in one :lol:

 

(if (and (eq (strcase (getvar 'DWGNAME)) "BATTERS.DWG")
        (tblsearch "LAYER" "BATTERS")
   )
 (progn
   (cond ((eq (strcase (getvar 'clayer)) "BATTERS")
          (setvar 'clayer "0")
         )
   )
   (setq l (entget (tblobjname "LAYER" "BATTERS")))
   (if (eq (logand 4 (cdr (assoc 70 l))) 4)
     (entmod (subst (cons 70 0) (assoc 70 l) l))
   )
   (entmod (subst (cons 70 1) (assoc 70 l) l))
 )
)

Posted
This is two in one :lol:

 

(if (and (eq (strcase (getvar 'DWGNAME)) "BATTERS.DWG")
        (tblsearch "LAYER" "BATTERS")
   )
 (progn
   (cond ((eq (strcase (getvar 'clayer)) "BATTERS")
          (setvar 'clayer "0")
         )
   )
   (setq l (entget (tblobjname "LAYER" "BATTERS")))
   (if (eq (logand 4 (cdr (assoc 70 l))) 4)
     (entmod (subst (cons 70 0) (assoc 70 l) l))
   )
   (entmod (subst (cons 70 1) (assoc 70 l) l))
 )
)

facepalm.giffacepalm.gif

 

I give up. I'm not sure why the need was felt to over complicate this thread for a beginning LISPER in the first place.

facepalm2.gif

Posted
This is two in one :lol:

 

What if the layer is frozen in new viewports? Or XRef dependent? Or indeed if any other Group 70 bit-codes are set? ;)

Posted
[ATTACH=CONFIG]30403[/ATTACH][ATTACH=CONFIG]30404[/ATTACH][ATTACH=CONFIG]30403[/ATTACH]

 

I give up. I'm not sure why the need was felt to over complicate this thread for a beginning LISPER in the first place.

 

Were not you the first adviser for all these steps ? :rofl:

Posted
Were not you the first adviser for all these steps ? :rofl:

Yes and I kept it simple and as close to his coding as possible.

Posted
What if the layer is frozen in new viewports? Or XRef dependent? Or indeed if any other Group 70 bit-codes are set? ;)

 

OMG ........ :o

Posted

To remove confusion for the OP, here is one way to approach the problem using entmod:

 

(defun c:test ( / e )
   (if
       (and
           (eq (strcase (getvar 'DWGNAME)) "BATTERS.DWG")
           (setq e (tblobjname "LAYER" "BATTERS"))
       )
       (progn
           (if (eq "BATTERS" (strcase (getvar 'CLAYER)))
               (setvar 'CLAYER "0")
           )
           (setq e (entget e))
           (entmod (subst (cons 70 (logior 1 (cdr (assoc 70 e)))) (assoc 70 e) e))
       )
   )
   (princ)
)

Posted

Don't forget to account for 0 being frozen.....we're are over complicating this.

Posted
Don't forget to account for 0 being frozen.....we're are over complicating this.

 

Good catch.

 

Solution:

(defun c:test ( / e l )
   (if
       (and
           (eq (strcase (getvar 'DWGNAME)) "BATTERS.DWG")
           (setq e (tblobjname "LAYER" "BATTERS"))
       )
       (progn
           (if (eq "BATTERS" (strcase (getvar 'CLAYER)))
               (progn
                   (setq l (entget (tblobjname "LAYER" "0")))
                   (entmod (subst (cons 70 (boole 4 1 (cdr (assoc 70 l)))) (assoc 70 l) l))
                   (setvar 'CLAYER "0")
               )
           )
           (setq e (entget e))
           (entmod (subst (cons 70 (logior 1 (cdr (assoc 70 e)))) (assoc 70 e) e))
       )
   )
   (princ)
)

 

But I agree - "-Layer" is far easier for this task.

Posted

Thanks guys for your help.

 

But if i wanted to repeat a freeze of multible layer with the condition of drawing name.

 

Is there a way to include an simple user interface like an excel sheet.

 

Sunny

 

P.S this is my completed code

(
(if (and (eq (strcase (getvar 'DWGNAME)) "GLRL-01DC-DWG-PW-GE-SMC-0202-A.DWG") ;ADD DWG NAME HERE IN CAPITALS
   )
 (if (eq (strcase (getvar 'CLAYER)) "X_PW_GE_SMC_LS_GINT|DP_BH103") ;ADD LAYER NAME HERE IN CAPITALS
   (command "_.-layer" "_T" "0" "_S" "0" "_F" "X_PW_GE_SMC_LS_GINT|DP_BH103" "") ;ADD LAYER NAME HERE IN CAPITALS
   (command "_.-layer" "_F" "X_PW_GE_SMC_LS_GINT|DP_BH103" "") ;ADD LAYER NAME HERE IN CAPITALS
 )
)
(if (and (eq (strcase (getvar 'DWGNAME)) "GLRL-01DC-DWG-PW-GE-SMC-0210-A.DWG") ;ADD DWG NAME HERE IN CAPITALS
   )
 (if (eq (strcase (getvar 'CLAYER)) "X_PW_GE_SMC_LS_GINT|DP_BH103") ;ADD LAYER NAME HERE IN CAPITALS
   (command "_.-layer" "_T" "0" "_S" "0" "_F" "X_PW_GE_SMC_LS_GINT|DP_TP17" "") ;ADD LAYER NAME HERE IN CAPITALS
   (command "_.-layer" "_F" "X_PW_GE_SMC_LS_GINT|DP_TP17" "") ;ADD LAYER NAME HERE IN CAPITALS
 )
)
(if (and (eq (strcase (getvar 'DWGNAME)) "GLRL-01DC-DWG-PW-GE-SMC-0215-A.DWG") ;;ADD DWG NAME HERE IN CAPITALS
   )
 (if (eq (strcase (getvar 'CLAYER)) "X_PW_GE_SMC_LS_GINT|SB_24") ;ADD LAYER NAME HERE IN CAPITALS
   (command "_.-layer" "_T" "0" "_S" "0" "_F" "X_PW_GE_SMC_LS_GINT|SB_24" "") ;ADD LAYER NAME HERE IN CAPITALS
   (command "_.-layer" "_F" "X_PW_GE_SMC_LS_GINT|SB_24" "") ;ADD LAYER NAME HERE IN CAPITALS
 )
)
)

and yes i relise that i am still using command call just give me a couple of day to look over you code entrys

Posted
and yes i relise that i am still using command call just give me a couple of day to look over you code entrys

 

Don't worry about using the Command call! It is more than sufficient for your purpose :)

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