Jump to content

Recommended Posts

Posted

It has been a while since I have been here, and a bit longer since I've needed to dig deep in ACAD. [blame the economy :P ]

 

I certainly hope this question isn't a little TOO newb-ish, so I apologize in advance! ;o

 

I have managed to never really use freezing or thawing when making my own drawings, so maybe I just don't understand it very well ... but here's what I want to do:

 

I am updating a set of plans that has a HORRIBLE lack of layer organization, enough so that I cannot spend the time to re-do to the whole thing and stay in budget.

 

The floor height is incorrect, and the easiest way I can think of to correct it would be if I could isolate the one layer I want to change so that nothing else around it will get affected.

Is that possible?

 

Can I select a layer and temporarily say "I'm only editing this one" without having to comb through all the other layers and turn them on/off by hand?

I certainly hope so ... it's literally the difference between a day long fix and a couple weeks. >:(

 

I am using ACAD 2004 for this one ...

 

Any ideas?

 

Thanks to you all, I'm very glad to see this community still the strongest around! :D

Posted

Try the command LAYISO,

 

 

oops just noticed the 2004 part, Express tools loaded ?

Posted

Express Tools > Layers > Layer Isolate command as mentioned above is the best way to go. You do know that it is possible to wholesale select layers with the use of the SHIFT key, right?

Posted (edited)

this is a nice alternative i use more than layiso. it will isolate the selected layers in addition to the current layer, or if you just enter it will isolate just the current layer. the next time you run the routine, it will turn back on all the layers you had turned off when isolating.

 

;;; ------------------------------------------------------------------------
;;;    LayerToggle.lsp v1.0
;;;
;;;    Copyright© 04.29.09
;;;    Alan J. Thompson (alanjt)
;;;
;;;    Permission to use, copy, modify, and distribute this software
;;;    for any purpose and without fee is hereby granted, provided
;;;    that the above copyright notice appears in all copies and
;;;    that both that copyright notice and the limited warranty and
;;;    restricted rights notice below appear in all supporting
;;;    documentation.
;;;
;;;    The following program(s) are provided "as is" and with all faults.
;;;    Alan J. Thompson DOES NOT warrant that the operation of the program(s)
;;;    will be uninterrupted and/or error free.
;;;
;;;    Allows user to isolate layers of selected object(s) and current layer.
;;;    On second execution of program, previously turned off layers are turned on.
;;;    Layer list, for reset, is stored as global variable '*LayerToggleLayers*'.
;;;
;;;    Thanks to Walt Bedinger, I really liked his idea and wanted to write my own.
;;;
;;;    Revision History:
;;;
;;; ------------------------------------------------------------------------

(defun c:, (/) (c:LayerToggle))
(defun c:LayerToggle (/              *error*        AT:Undo
                     AT:SS->List    AT:LayerList   AT:LayerListOff
                     #SSList        #SSLayers
                    )

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SUBROUTINES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;; error handler
 (defun *error* (msg)
   (AT:Undo "V" "E")
   (if
     (not
       (member
         msg
         '("console break" "Function cancelled" "quit / exit abort")
       ) ;_ member
     ) ;_ not
      (princ (strcat "\nError: " msg))
   ) ;_ if
 ) ;_ defun


;;; ------------------------------------------------------------------------
;;;    AT:Undo.lsp v1.0
;;;    (SubRoutine)
;;;
;;;    Copyright© 03.23.09
;;;    Alan J. Thompson (alanjt)
;;;
;;;    Permission to use, copy, modify, and distribute this software
;;;    for any purpose and without fee is hereby granted, provided
;;;    that the above copyright notice appears in all copies and
;;;    that both that copyright notice and the limited warranty and
;;;    restricted rights notice below appear in all supporting
;;;    documentation.
;;;
;;;    Undo "BEGIN" and "END" options, with choice of using "COMMAND"
;;;    or "VLA". User inputs coding choice (Command or VLA) and the
;;;    choice to issue an 'undo begin' or 'undo end'.
;;;
;;;    Arguments:
;;;    #CommandVLA - Option to use command or VLA for undo marking.
;;;              ("V" for VLA, "C" for Command)
;;;    #BeginEnd - Option to issue an 'Undo Begin' or 'Undo End'.
;;;            ("B" for Begin, "E" for End).
;;;
;;;    Examples:
;;;    (defun c:TEST ( / p1 p2 )
;;;          (AT:Undo "C" "B")
;;;          (and
;;;            (setq p1 (getpoint "\nPoint 1: "))
;;;            (setq p2 (getpoint p1 "\nPoint 2: "))
;;;            (command "_.line" p1 p2 ""
;;;                     "_.circle" p1 2
;;;                     "_.circle" p2 2))
;;;            (AT:Undo "C" "E"))
;;;
;;;    Revision History:
;;;
;;; ------------------------------------------------------------------------

 (defun AT:Undo (#CommandVLA #BeginEnd / #OldCmdecho)
   (if
     (and
       (member (strcase #CommandVLA) (list "C" "V"))
       (member (strcase #BeginEnd) (list "B" "E"))
     ) ;_ and
      (cond
        ;; COMMAND Undo Options
        ((eq "C" (strcase #CommandVLA))
         (setq #OldCmdecho (getvar "cmdecho"))
         (setvar "cmdecho" 0)
         (cond
           ;; Undo Begin
           ((eq "B" (strcase #BeginEnd)) (command "_.undo" "_be"))
           ;; Undo End
           ((eq "E" (strcase #BeginEnd)) (command "_.undo" "_e"))
         ) ;_ cond
         (setvar "cmdecho" #OldCmdecho)
        )
        ;; VLA Undo Options
        ((eq "V" (strcase #CommandVLA))
         (cond
           ;; Undo Begin
           ((eq "B" (strcase #BeginEnd))
            (vla-StartUndoMark
              (vla-get-ActiveDocument
                (vlax-get-Acad-Object)
              ) ;_ vla-get-ActiveDocument
            ) ;_ vla-StartUndoMark
           )
           ;; Undo End
           ((eq "E" (strcase #BeginEnd))
            (vla-EndUndoMark
              (vla-get-ActiveDocument
                (vlax-get-Acad-Object)
              ) ;_ vla-get-ActiveDocument
            ) ;_ vla-EndUndoMark
           )
         ) ;_ cond
        )
      ) ;_ cond
   ) ;_ if
 ) ;_ defun


;;; Convert selection set to list of ename or vla objects
;;; #Selection - SSGET selection set
;;; #VLAList - T for vla objects, nil for ename
;;; Alan J. Thompson, 04.20.09
(defun AT:SS->List (#Selection #VlaList / #List)
 (and #Selection
      (setq #List (vl-remove-if
                    'listp
                    (mapcar 'cadr (ssnamex #Selection))
                  ) ;_ vl-remove-if
      ) ;_ setq
      (if #VlaList
        (setq #List (mapcar 'vlax-ename->vla-object #List))
      ) ;_ if
 ) ;_ and
 #List
) ;_ defun


;;; Create list of layer objects in drawing
;;; Alan J. Thompson, 04.16.09
 (defun AT:LayerList (/ #Layers #List)
   (setq #Layers (vla-get-Layers
                   (vla-get-activedocument
                     (vlax-get-acad-object)
                   ) ;_ vla-get-activedocument
                 ) ;_ vla-get-Layers
   ) ;_ setq
   (vlax-for x #Layers
     (setq #List (cons x #List))
   ) ;_ vlax-for
   (vlax-release-object #Layers)
   #List
 ) ;_ defun


;;; Create list of layer objects in drawing (turned off)
;;; Alan J. Thompson, 04.28.09
 (defun AT:LayerListOff (/ #Layers #List)
   (setq #Layers (vla-get-Layers
                   (vla-get-activedocument
                     (vlax-get-acad-object)
                   ) ;_ vla-get-activedocument
                 ) ;_ vla-get-Layers
   ) ;_ setq
   (vlax-for x #Layers
     (if (eq (vla-get-LayerOn x) :vlax-false)
       (setq #List (cons x #List))
     ) ;_ if
   ) ;_ vlax-for
   (vlax-release-object #Layers)
   #List
 ) ;_ defun


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MAIN ROUTINE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


 (vl-load-com)

 (AT:Undo "V" "B")

 (cond
   ;; global variable *LayerToggleLayers* not nil
   (*LayerToggleLayers*
    (mapcar
      '(lambda (x)
         (if (not (member x *LayerToggleLayers*))
           (vla-put-layeron x :vlax-true)
         ) ;_ if
       ) ;_ lambda
      (AT:LayerList)
    ) ;_ mapcar
    (setq *LayerToggleLayers* nil)
    (prompt "\nLayers have been reset!")
   )

   ;; global variable *LayerToggleLayers* nil
   ((not *LayerToggleLayers*)
    (or (ssget "_I")
        (prompt (strcat "\nSelect objects on layers to isolate <"
                        (getvar "clayer")
                        ">: "
                ) ;_ strcat
        ) ;_ prompt
    ) ;_ or
    (cond
      ((or (setq #SSList (AT:SS->List (ssget) T))
           (setq
             #SSLayers (list (vlax-ename->vla-object
                               (tblobjname "layer" (getvar "clayer"))
                             ) ;_ vlax-ename->vla-object
                       ) ;_ list
           ) ;_ setq
       ) ;_ or

       ;;set global variable of off layers
       (or (foreach x (AT:LayerList)
             (if (eq (vla-get-layeron x) :vlax-false)
               (setq *LayerToggleLayers* (cons x *LayerToggleLayers*))
             ) ;_ if
             *LayerToggleLayers*
           ) ;_ foreach
           (setq *LayerToggleLayers* (list ""))
       ) ;_ or

       (cond
         ;; have selection of objects, time to rip out layer list & add current layer (if not member)
         ((not #SSLayers)
          (mapcar
            '(lambda (x)
               (if (not (member
                          (vlax-ename->vla-object
                            (tblobjname
                              "layer"
                              (vla-get-layer x)
                            ) ;_ tblobjname
                          ) ;_ vlax-ename->vla-object
                          #SSLayers
                        ) ;_ member
                   ) ;_ not
                 (setq #SSLayers (cons (vlax-ename->vla-object
                                         (tblobjname
                                           "layer"
                                           (vla-get-layer x)
                                         ) ;_ tblobjname
                                       ) ;_ vlax-ename->vla-object
                                       #SSLayers
                                 ) ;_ cons
                 ) ;_ setq
               ) ;_ if
             ) ;_ lambda
            #SSList
          ) ;_ mapcar

          ;; if current layer is not member of list, add to it
          (if (not (member (getvar "clayer")
                           (mapcar 'vla-get-name #SSLayers)
                   ) ;_ member
              ) ;_ not
            (setq
              #SSLayers
               (cons (vlax-ename->vla-object
                       (tblobjname "layer" (getvar "clayer"))
                     ) ;_ vlax-ename->vla-object
                     #SSLayers
               ) ;_ cons
            ) ;_ setq
          ) ;_ if
         )
       ) ;_ cond

       ;; have layer list from selection, time to isolate list
       (mapcar
         '(lambda (x)
            (if (not (member x #SSLayers))
              (vla-put-layeron x :vlax-false)
            ) ;_ if
            (vlax-release-object x)
          ) ;_ lambda
         (AT:LayerList)
       ) ;_ mapcar

       ;; isolation complete, print results to commandline
       (cond
         ;; only current layer isolated
         ((eq (length #SSLayers) 1)
          (prompt (strcat "\nThe current layer \""
                          (getvar "clayer")
                          "\" has been isolated!"
                  ) ;_ strcat
          ) ;_ prompt
         )
         ;; more than just current layer isolated
         (T
          (print (mapcar 'vla-get-name #SSLayers))
          (prompt (strcat "\n "
                          (rtos (length #SSLayers) 2 0)
                          " layers have been isolated!"
                  ) ;_ strcat
          ) ;_ prompt
         )
       ) ;_ cond
      )
    ) ;_ cond
   )
 ) ;_ cond

 (AT:Undo "V" "E")

 (princ)
) ;_ defun

Edited by alanjt
Posted

Wow, thanks!

Couldn't find that anywhere ... feel like a complete newb again, instead just a partial newb! LOL

 

Mark: No, I had no clue about that ... do you mean you can select more layers than one to perform an operation, or that it will isolate more than one?

 

That LISP routine is great BTW!

 

Thanks again guys!

Lifesavers! :D

 

umop-3p!sdn

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