TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Amsterdammed on February 07, 2006, 11:06:28 AM

Title: set layer to no plot
Post by: Amsterdammed on February 07, 2006, 11:06:28 AM
Hello everybody,
Is there a way to set a layer on no plot with entmod?

Thanks in advance,

Bernd
Title: Re: set layer to no plot
Post by: Jeff_M on February 07, 2006, 11:34:19 AM
Yes....here is a small lisp function I posted to the Adesk newsgroup a few weeks ago to toggle the noplot status of the given layer:
Code: [Select]
;;usage (noplotlay "0")

(defun noplotlay (layname / lay entlist assoc290)
  (if (setq lay (tblobjname "LAYER" layname))
    (progn
      (setq entlist (entget lay)
     assoc290 (assoc 290 entlist)
     )
      (entmod (subst (cons 290 (- 1 (cdr assoc290))) assoc290 entlist))
      )
    )
  (princ)
  )
Title: Re: set layer to no plot
Post by: Amsterdammed on February 07, 2006, 12:15:11 PM
Jeff,
Not only that you solved my problem, I also learned a lot about the whole table thing. I was looking with tblsearch and did not find anything. Now I see…  :roll:
Thanks a lot

Bernd
Title: Re: set layer to no plot
Post by: CADmium on February 08, 2006, 01:42:16 AM
to set /unset Bits it's better to use the boole / logand / logior functions. Only -1 can produce an error when GC 290 = 0 ..

Code: [Select]
(defun DT:LAYER-PUT-PLOTTABLE-GC (LAYER PLOTABLE? / DATA)
  (if (not LAYER) (setq LAYER (getvar "CLAYER")))
  (and(setq DATA (tblobjname "LAYER" LAYER))
      (setq DATA (entget DATA))
      (if(not(member PLOTABLE? '(nil 0 "no")))
        (entmod(subst(cons 290 (boole 7(cdr(assoc 290 DATA))1))(assoc 290 DATA)DATA))
        (entmod(subst(cons 290 (boole 2(cdr(assoc 290 DATA))1))(assoc 290 DATA)DATA))
      )
  )
)

usage:
(DT:LAYER-PUT-PLOTTABLE-GC "0" nil)
Title: Re: set layer to no plot
Post by: Kerry on February 08, 2006, 02:08:19 AM
CADmium,

Personal preference  < and probably also more conventional >  :

PLOTABLE? would be T or nil

and the test would become
(if PLOTABLE?
   (bla lba ..
   ;else
   (bla bla
)
Title: Re: set layer to no plot
Post by: CADmium on February 08, 2006, 04:22:30 AM
CADmium,

Personal preference  < and probably also more conventional >  :

PLOTABLE? would be T or nil

and the test would become
(if PLOTABLE?
   (bla lba ..
   ;else
   (bla bla
)

(http://www.cadwiesel.de/T2/www/images/ka.gif) .. how you like it .. i think , this changes are not a problem .. maybe , the member-function is confusing
Title: Re: set layer to no plot
Post by: Kerry on February 08, 2006, 04:24:21 AM
>>> .. maybe , the member-function is confusing

hehehehe

nope, not at all :-)
Title: Re: set layer to no plot
Post by: Jeff_M on February 08, 2006, 09:39:11 AM
to set /unset Bits it's better to use the boole / logand / logior functions. Only -1 can produce an error when GC 290 = 0 ..
I don't follow.....if I want a pure toggle, turn on/off plotting no matter what it is currently set to I see no need for using boole.
(- 1 0) = 1
(- 1 1) = 0
Very simple so that those trying to learn can understand it. And although I recall having used boole in the past, relooking at the help for it I found myself confused in it's use until I sat down and toyed with it.
Title: Re: set layer to no plot
Post by: CADmium on February 08, 2006, 10:43:05 AM
@Jeff_M :sorry i read it as (- (cdr assoc290) -1) <dream>   , but boole is the better way ... universally .. for instance when you also want to manipulate the Freeze-Bit or the Locked Bit of a layer ( both GC 70)



for toogle a bool - 0 or 1 - ...  I also  use  (- 1 Bool)
Title: Re: set layer to no plot
Post by: CAB on February 08, 2006, 11:53:09 AM
to set /unset Bits it's better to use the boole / logand / logior functions. Only -1 can produce an error when GC 290 = 0 ..

Code: [Select]
(defun DT:LAYER-PUT-PLOTTABLE-GC (LAYER PLOTABLE? / DATA)
  (if (not LAYER) (setq LAYER (getvar "CLAYER")))
  (and(setq DATA (tblobjname "LAYER" LAYER))
      (setq DATA (entget DATA))
      (if(not(member PLOTABLE? '(nil 0 "no")))
        (entmod(subst(cons 290 (boole 7(cdr(assoc 290 DATA))1))(assoc 290 DATA)DATA))
        (entmod(subst(cons 290 (boole 2(cdr(assoc 290 DATA))1))(assoc 290 DATA)DATA))
      )
  )
)

usage:
(DT:LAYER-PUT-PLOTTABLE-GC "0" nil)

Another way to phrase it.
Code: [Select]
(defun dt:layer-put-plottable-gc (layer plotable? / data n)
  (or layer (setq layer (getvar "CLAYER")))
  (setq n (if (or plotable? (member plotable? '(1 "yes" "YES")) 7 2)))
  (and (setq data (tblobjname "LAYER" layer))
       (setq data (entget data))
       (entmod (subst (cons 290 (boole n (cdr (assoc 290 data)) 1)) (assoc 290 data) data))
  )
)
Title: Re: set layer to no plot
Post by: Jeff_M on February 08, 2006, 12:08:16 PM
This
Code: [Select]
'(1 "yes" "YES") should be expanded to this
Code: [Select]
'(1 "yes" "YES" "Y" "Yes" "OK" Yep" "Youbetcha" "Alrightythen" "UhHuh")which brings me to my point.....if you are going to do something like this, then I agree with Kerry
Quote from: Kerry Brown
PLOTABLE? would be T or nil

Alan, this makes no sense to me:
Code: [Select]
(or plotable? (member plotable? '(1 "yes" "YES")))if plotable is nil it will fail the first test which means it will also fail the second test, if it's not nil then it will never make it to the second test (and you have a misplaced ")")
Title: Re: set layer to no plot
Post by: CAB on February 08, 2006, 12:33:31 PM
OK, I screwed that up.:)
Let me try again with a simpler version.
I did test this one. :oops:
Code: [Select]
;;  layer must be string layer name or nil for current
;;  plotable?  must be nil or not nil
(defun dt:layer-put-plottable-gc (layer plotable? / data)
  (or layer (setq layer (getvar "CLAYER")))
  (and (setq data (tblobjname "LAYER" layer))
       (setq data (entget data))
       (entmod (subst (cons 290 (if plotable? 1 0)) (assoc 290 data) data))
  )
)
Title: Re: set layer to no plot
Post by: zoltan on February 15, 2006, 10:15:49 AM
I think he meant to do this:
Code: [Select]
(and plotable? (member plotable? '(T 1 "yes" "YES")))

but I agree with CAB:
Code: [Select]
(cons 290 (if plotable? 1 0))

who cares what the original value was.  We are setting it explicitly anyway.
Title: Re: set layer to no plot
Post by: Amsterdammed on February 16, 2006, 08:45:45 AM
Gentlemen,
I asked a simple Question......
Title: Re: set layer to no plot
Post by: t-bear on February 16, 2006, 01:25:56 PM
.......and got 3,427,633 simple solutions.............LOL
The neat part??  MOST of them even work!!  What a place!
Title: Re: set layer to no plot
Post by: CADaver on February 16, 2006, 11:12:53 PM
Hello everybody,
Is there a way to set a layer on no plot with entmod?

Thanks in advance,

Bernd

yes
Title: Re: set layer to no plot
Post by: CAB on February 16, 2006, 11:27:10 PM
Bernd

Is that simple answer you were looking for?   :lmao: