Author Topic: Multiple layer isolate  (Read 9000 times)

0 Members and 1 Guest are viewing this topic.

TJAM51

  • Guest
Multiple layer isolate
« on: March 17, 2006, 11:51:51 AM »
Is there a lisp that will allow you to isolate multiple layers?


Thanks

T.Willey

  • Needs a day job
  • Posts: 5248
Re: Multiple layer isolate
« Reply #1 on: March 17, 2006, 11:58:58 AM »
There is one with express tools.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

TJAM51

  • Guest
Re: Multiple layer isolate
« Reply #2 on: March 17, 2006, 12:00:00 PM »
I am using 2002 LT with LT-Extender to run lisp. I do not have express tools.

T.Willey

  • Needs a day job
  • Posts: 5248
Re: Multiple layer isolate
« Reply #3 on: March 17, 2006, 12:09:58 PM »
Maybe something like
Code: [Select]
(defun c:LayIso (/ ss Ent Str LayName)

(setq Str "")
(if (setq ss (ssget))
 (while (setq Ent (ssname ss 0))
  (if (not (vl-string-search (setq LayName (cdr (assoc 8 (entget Ent)))) Str))
   (if (= Str "")
    (setq Str LayName)
    (setq Str (strcase Str ", " LayName))
   )
  )
  (ssdel Ent ss)
 )
)
(if Str
 (command "_.layer" "_set" LayName "_off" "*" "_no" "_on" Str "")
)
(princ)
)

Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

TJAM51

  • Guest
Re: Multiple layer isolate
« Reply #4 on: March 17, 2006, 01:03:57 PM »
The routine did not work....thanks for the effort.



T.Willey

  • Needs a day job
  • Posts: 5248
Re: Multiple layer isolate
« Reply #5 on: March 17, 2006, 01:11:18 PM »
What did it say?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

TJAM51

  • Guest
Re: Multiple layer isolate
« Reply #6 on: March 17, 2006, 01:32:48 PM »
Select objects:
; error: too many arguments

CAB

  • Global Moderator
  • Seagull
  • Posts: 10400
Re: Multiple layer isolate
« Reply #7 on: March 17, 2006, 01:36:19 PM »
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

TJAM51

  • Guest
Re: Multiple layer isolate
« Reply #8 on: March 17, 2006, 01:51:29 PM »
Thanks guys...no luck here is the error reading


Pick layers to keep on. Enter when done
; error: no function definition: VLAX-GET-ACAD-OBJECT

CAB

  • Global Moderator
  • Seagull
  • Posts: 10400
Re: Multiple layer isolate
« Reply #9 on: March 17, 2006, 02:06:23 PM »
Maybe the LTextender will only do Plain Lisp, I seem to remember that.
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Exxit

  • Guest
Re: Multiple layer isolate
« Reply #10 on: March 17, 2006, 02:08:22 PM »
TJAM51,

You have got the Extender, and don't use the Express Tools V1-9 :lol:? Search in the www for a download...
L.

Jeff_M

  • King Gator
  • Posts: 4042
  • C3D user & customizer
Re: Multiple layer isolate
« Reply #11 on: March 17, 2006, 02:09:28 PM »
Yep, no ActiveX or (vl-anything)....
Code: [Select]
removed bogus code, next time I'll look more closely at what I'm doing.....
« Last Edit: March 17, 2006, 02:45:20 PM by Jeff_M »

TJAM51

  • Guest
Re: Multiple layer isolate
« Reply #12 on: March 17, 2006, 02:26:59 PM »
Still no work......possibly the LT Extender will not allow it to work...here is the error reading...


Command: LAYISO

Select objects on layer to Isolate:
Select objects: 1 found

Select objects: 1 found, 2 total

Select objects:

Invalid option keyword.
; error: Function cancelled
Enter an option
[?/Make/Set/New/ON/OFF/Color/Ltype/LWeight/Plot/Freeze/Thaw/LOck/Unlock/stAte]:

Jeff_M

  • King Gator
  • Posts: 4042
  • C3D user & customizer
Re: Multiple layer isolate
« Reply #13 on: March 17, 2006, 02:40:30 PM »
Since I don't have LT or LT-Extender it's really hard to say. I know that it works here in Acad2002 & Acad2006.

Try turning off a layer maually at the command line and paste back everything that gets output.

To start the layer command without the Dialog, use :
Command: -layer

Jeff_M

  • King Gator
  • Posts: 4042
  • C3D user & customizer
Re: Multiple layer isolate
« Reply #14 on: March 17, 2006, 02:42:27 PM »
Actually, it will probably give that error if you try to turn off the current layer....

Oh, carp.....
I'm doing it backwards.....disregard my previous code.....
* Jeff_M goes back to drawing board with a fressh cup of coffee......

Jeff_M

  • King Gator
  • Posts: 4042
  • C3D user & customizer
Re: Multiple layer isolate
« Reply #15 on: March 17, 2006, 02:50:38 PM »
Try this....if the current layer gets turned off then the first object's layer will become current.
Code: [Select]
(defun c:LayIso (/ ss idx ent lay lays)
  (prompt "\nSelect objects on layer to Isolate: ")
  (if (setq ss (ssget))
    (progn
      (setq echo (getvar "cmdecho"))
      (setvar "cmdecho" 0)
      (setq idx -1)
      (while (setq ent (ssname ss (setq idx (1+ idx))))
(setq lay (cdr (assoc 8 (entget ent))))
(if (not (member lay lays))
  (setq lays (cons lay lays))
  )
)
      (if lays
(progn
  (command "undo" "be")
  (command ".layer" "off" "*" "y" "")
  (mapcar '(lambda (x)
     (command ".layer" "on" x "")
     )
  lays)
  (command ".layer" "s" (last lays) "")
  (command "undo" "end")
  )
)
      (setvar "cmdecho" echo)
      )
    )
  (princ)
  )

TJAM51

  • Guest
Re: Multiple layer isolate
« Reply #16 on: March 17, 2006, 03:04:42 PM »
It works...thanks bunches :-D

CAB

  • Global Moderator
  • Seagull
  • Posts: 10400
Re: Multiple layer isolate
« Reply #17 on: March 17, 2006, 03:18:09 PM »
Not to happy with the code but here is one that will freeze all but selected layers
The selected layers are turned off temporally as you select them.

Code: [Select]
;;  CAB 08.21.08  [ Limited Testing ]  version 3
;;  User pick of layers to remain Thawed, freeze all others
;;  Picked layers turn off as picked, when Enter is pressed
;;  picked layers are thawed & turned on and all others are frozen
;;
;;  modified to allow current layer to be frozen, makes the first
;;  thawed layer current
;;
;;  If a layer in an xref is selected the layer the xref is on can
;;  not be frozen
;;
;;  Layer 0 in an xref will not be frozen
;;
;;  added uiso to restore the previous layer states
;;
(defun c:liso (/ laylst thalst ent lname xrlays)
 (vl-load-com)
  ;; get current layer settings
  (defun getlayerdata (doc / lst)
    (vlax-for layObj (vla-get-layers doc)
      (setq lst (cons (list layObj
                            (vla-get-freeze layObj)
                            (vla-get-layeron layObj)
                      )
                      lst)))
    lst
  )

  (defun xrefp (ent / elist blist)
    (and
      (setq elist (entget ent))
      (setq blist (entget (tblobjname "BLOCK" (cdr (assoc 2 elist)))))
      (= 4 (logand (cdr (assoc 70 blist)) 4))
    )
  )

  (defun LayerOff (layname doc) ; added for version 3
    (vla-put-LayerOn (vla-item (vla-get-layers doc) layname) :vlax-false)
  )

  (command ".undo" "begin")
  (setq *laysts (getlayerdata (vla-get-activedocument (vlax-get-acad-object)))
        *clayer (getvar "clayer")
  )

  (prompt "\nLayers picked will turn off during selection.")
  (while (setq ent (nentsel "\nPick layers to keep thawed. Enter when done"))
    (setq lname (cdr (assoc 8 (entget (car ent)))))
    (if (vl-position lname xrlays)
      (prompt "\nFlagged xref layer can not be frozen.")
      (if (and (= lname "0") (cadddr ent) (xrefp (last (nth 3 ent))))
        (prompt "\nLayer 0 in xref can not be frozen.")
        (progn
        (setq thalst (cons lname thalst))
        (LayerOff lname (vla-get-activedocument (vlax-get-acad-object)))
        (if (and (cadddr ent) (xrefp (car (nth 3 ent))))
          (progn    ; save the xref layer
            (setq xrlays (cons (cdr (assoc 8 (entget (last (nth 3 ent))))) xrlays)
                  thalst (cons (car xrlays) thalst)
            )
          )
        )
        )
      )
    )
  )
  (if thalst
    (progn
      (setq laylst (list (cdr (assoc 2 (tblnext "layer" t))))
            clayer (getvar "clayer")
      )
      (while (setq lay (cdr (assoc 2 (tblnext "layer"))))
        (if (and lay
                 (not (member lay thalst))
                 (/= lay clayer)
            )
          (setq laylst (cons lay laylst))
        )
      )
      (if (vl-position *clayer laylst)
        (setvar "clayer" (car thalst))
      )
      (command "._Layer")
      (mapcar '(lambda (x) (command "_f" x)) laylst)
      (command "")
      (command "._Layer")
      (mapcar '(lambda (x) (command "_ON" x)) thalst)
      (command "")
    )
  )
  (command ".undo" "end")
  (princ)
)
(prompt "\n*-*  Layers Isolate loaded, Enter LayISO to run.  *-*")
(princ)



;;  restore previous layer settings
(defun c:uiso (/ doc)
  (setq doc    (vla-get-activedocument (vlax-get-acad-object))
        clayer (vla-get-activelayer doc)
  )
  (if *laysts
    (progn
      (vlax-for layObj (vla-get-layers doc)
        (if (and (setq lyrdat (assoc layObj *laysts))
                 (not (equal clayer layObj))
            )
          (progn
            (vla-put-freeze layObj (cadr lyrdat))
            (vla-put-layeron layObj (caddr lyrdat))
            (if (= *clayer (vla-get-name layObj))
              (vla-put-activelayer doc layObj)
            )
          )
        )
      )
      (setq lyrdat (assoc clayer *laysts))
      (if (/= *clayer (vla-get-name (car lyrdat)))
        (vla-put-freeze (car lyrdat) (cadr lyrdat))
      )
      (vla-put-layeron (car lyrdat) (caddr lyrdat))
      (vla-regen doc acactiveviewport)
    )
  )
)

<edit: code updated>
« Last Edit: August 13, 2010, 12:55:01 PM by CAB »
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.