Author Topic: arrrgh layer filters  (Read 2242 times)

0 Members and 1 Guest are viewing this topic.

Davez

  • Guest
arrrgh layer filters
« on: June 01, 2005, 11:28:34 PM »
Layer filters are just wrong!

Nobody in our office uses these but yet it is stealing gigs of space on our server. I have a script file to batch delete but is there any way to just modify autocad so the standard is no layer filters? Files are droping up to 80% in size after deleting this useless feature!!

been searching for a while now, the best I found is scriptpro to batch.

thx

hendie

  • Guest
arrrgh layer filters
« Reply #1 on: June 02, 2005, 06:00:05 AM »
you could run a lisp at startup that automatically deleted any layer filters

nivuahc

  • Guest
arrrgh layer filters
« Reply #2 on: June 02, 2005, 07:34:33 AM »
Code: [Select]
(defun c:FilterKiller (/)
   (vl-Load-Com)
   (vl-Catch-All-Apply
     '(lambda ()
        (vla-Remove
     (vla-GetExtensionDictionary
       (vla-Get-Layers
         (vla-Get-ActiveDocument
           (vlax-Get-Acad-Object)
         )
       )
     )
     "ACAD_LAYERFILTERS"
        )
      )
   )
)

daron

  • Guest
arrrgh layer filters
« Reply #3 on: June 02, 2005, 07:48:25 AM »
Just take the above lisp and remove the (defun... line and the very last ) closing parenthesis and put the rest in a lisp that loads every time you open a drawing.

ronjonp

  • Needs a day job
  • Posts: 7533
arrrgh layer filters
« Reply #4 on: June 02, 2005, 10:57:08 AM »
On another topic...does anyone have a lisp that will create a list of all drawings in subdirectories up to 15 deep that can be later run as a script?

I have used ezscript but it only searches 1 or 2 deep.

Thanks,

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
arrrgh layer filters
« Reply #5 on: June 02, 2005, 11:03:22 AM »
It's rather easy to write a recursive directory scanner but why not just use DOSLIB's dos_find function and then write the results to a file?

e.g.

(setq myFileList (dos_file "x:\\ParentFolder\\*.dwg" 0))

Alternatively, at a dos command prompt one can just use indirection:

C:> dir x:\ParentFolder\*.dwg /b /s /on > x:\MyFileList.txt
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

whdjr

  • Guest
arrrgh layer filters
« Reply #6 on: June 02, 2005, 11:17:04 AM »
Here's one I wrote to delete certain types of files in folders.
You can modify it if you don't need to do all that.


Code: [Select]
(defun *list_folders* (path sub)
  (defun get_folders (folder / f)
    (mapcar '(lambda (x)
      (setq f (strcat folder "\\" x))
      (if sub
(cons f (apply 'append (get_folders f)))
      )
    )
   (cddr (vl-directory-files folder nil -1))
    )
  )
  (cons path (apply 'append (get_folders path)))
)

(defun get_files (path exts)
  (apply 'append
(mapcar '(lambda (x)
   (mapcar '(lambda (y)
      (mapcar '(lambda (z) (strcat x "\\" z))
      (vl-directory-files x y 1)
      )
    )
   exts
   )
 )
path
)
  )
)


;;;usage
;;;(c:all_files T) T=search sub folders nil=don't search subfolders
(defun c:all_files (sub_folders / lst exts)
  (setq exts '("*.bak" "*.bk*" "*.$$$" "*.ac$"))
  (setq lst
(apply 'append
(get_files
 (*list_folders*
   (acet-ui-pickdir
     (strcat "Searches for all files that match this "
     "criteria: *.bak, *.bk*, *.$$$, and *.ac$"
     )
     "Y:\\Common\\Projects"
     "Select a Folder"
   )
   sub_folders
 )
 exts
)
)
  )
  (mapcar 'vl-file-delete lst)
  (princ)
)


WARNING:
If code posted above is run as is, it will delete files.  Do not test fully unless you understand the code.

ronjonp

  • Needs a day job
  • Posts: 7533
arrrgh layer filters
« Reply #7 on: June 02, 2005, 11:46:18 AM »
Thanks guys.

Hey Will...your ctabs routine rocks. Have you updated it yet to accept viewports?

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

whdjr

  • Guest
arrrgh layer filters
« Reply #8 on: June 02, 2005, 12:08:35 PM »
Quote from: ronjonp
Thanks guys.

Hey Will...your ctabs routine rocks. Have you updated it yet to accept viewports?

Ron

You'll have to remind me a little bit more as I can't seem to find it.

ronjonp

  • Needs a day job
  • Posts: 7533
arrrgh layer filters
« Reply #9 on: June 02, 2005, 12:58:38 PM »
Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;ctabs.lsp by Will DeLoach    Copyright 2004                      ;;;
;;;                                                                 ;;;
;;;Description:                                                     ;;;
;;;The user selects an object on screen (not a viewport) and then it;;;
;;;is copied on all other layout tabs in the same location as the   ;;;
;;;object that was selected.                                        ;;;
;;;                                                                 ;;;
;;;This was tested on AutoCad 2000                                  ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;This loads all the activeX functions for those running A2K.      ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(vl-load-com)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;This is a rewrite of the ssget function to handle missed picks   ;;;
;;;and right clicks.  It also filters out viewports because they    ;;;
;;;wreck havoc in this routine.                                     ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ss_get (msg filter / ent)
  (while (not ent)
    (princ msg)
    (cond ((setq ent (ssget filter)))
     ((= (getvar "ErrNo") 52)
      (exit)
     )
     ((null ent)
      (princ "\nSelection missed.  Please try again.")
     )
    )
  )
  ent
)
;;;
;;;
;;;
(defun ssnames (selection_set / num lst)
  (repeat (setq num (sslength selection_set))
    (setq num (1- num)
     lst (cons (ssname selection_set num) lst)
    )
  )
  lst
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;This is a subr to collect all the layout tab objects into a list.;;;
;;;This subr removes the "Model" tab and the current tab as well.   ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun *layout_list* (doc / lst)
  (vlax-map-collection
    (vla-get-layouts doc)
    '(lambda (x) (setq lst (cons x lst)))
  )
  (vl-remove (vla-get-activelayout doc)
        (cdr
          (*sort* lst 'vla-get-taborder)
        )
  )
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;This is a subr to sort the layout tabs base on their taborder.   ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun *sort* (lst func)
  (vl-sort lst
      '(lambda (e1 e2)
         (< ((eval func) e1) ((eval func) e2))
       )
  )
)
;;;
;;;
;;;
(defun getSelectedItems   (tilename AllItemsList / indexes)
  (if (setq indexes (get_tile tilename))
    (setq indexes (read (strcat "(" indexes ")"))
     indexes (mapcar '(lambda (n) (nth n AllItemsList))
           indexes
        )
    )
  )
  indexes
)
;;;
;;;
;;;
(defun get_selected_layouts (lst / id)
 ;
  (defun on_list_pick ()
    (if   (= (get_tile "layout_list") "")
      (mode_tile "select" 1)
      (mode_tile "select" 0)
    )
  )
 ;
  (and (setq id (load_dcl))
       (start_list "layout_list")
       (mapcar 'add_list (mapcar 'vla-get-name lst))
       (not (end_list))
       (action_tile "cancel" "(done_dialog 0)")
       (action_tile
    "select"
    (strcat
      "(setq selection (getSelectedItems \"layout_list\" lst))"
      "(done_dialog 1)"
    )
       )
       (action_tile "layout_list" "(on_list_pick)")
       (not (mode_tile "select" 1))
       (start_dialog)
       (not (unload_dialog id))
  )
  (if selection
    selection
    *error*
  )
)
;;;
;;;
;;;
(defun load_dcl   (/ dcl dcl_id)
  (setq dcl "ctabs.dcl")
  (while
    (if   (minusp (setq dcl_id (load_dialog dcl)))
      (setq dcl   (getfiled "Select correct DCL file location: "
           dcl
           "dcl"
           (+ 8 128)
      )
      )
      (not (new_dialog "ctabs" dcl_id))
    )
  )
  dcl_id
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;This is the main routine.  It copys an object to all selected    ;;;
;;;layout tabs at the exact location of the selected object.        ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:ctabs (/ ss objs adoc)
  (cond   ((= (getvar "TILEMODE") 1)
    (princ "\nThis command does not work in Modelspace.  ")
   )
   ((> (getvar "CVPORT") 1)
    (princ "\nThis command does not work in a Viewport.  ")
   )
   ((not
      (setq ss (ss_get
            "\nSelect an Object to copy to selected Layout tabs:  "
            '((-4 . "<NOT") (0 . "VIEWPORT") (-4 . "NOT>"))
          )
      )
    )
    (princ "\nError:  Function Cancelled ")
   )
   (T
    (setq objs (mapcar 'vlax-ename->vla-object (ssnames ss))
          adoc (vla-get-activedocument (vlax-get-acad-object))
    )
    (mapcar '(lambda (x)
          (vla-copyobjects
            adoc
            (vlax-safearray-fill
         (vlax-make-safearray
           vlax-vbobject
           (cons 0 (1- (length objs)))
         )
         objs
            )
            (vla-get-block x)
          )
        )
       (get_selected_layouts (*layout_list* adoc))
    )
   )
  )
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

whdjr

  • Guest
arrrgh layer filters
« Reply #10 on: June 02, 2005, 02:02:04 PM »
Ok, I remember that one.  I renamed it and that's why I couldn't find it.
How do you want it to treat viewports?

Do you want it to copy the shape of the viewport?, scale?, layer settings?, or everything about a viewport? :lol:

Ok I'll get busy on it.  I got tied up on something else and forgot to go back.  You know...WORK! :shock:  :lol:

whdjr

  • Guest
arrrgh layer filters
« Reply #11 on: June 02, 2005, 02:03:37 PM »
By the way, what's the link to that post?
So I can add to it when I update it.

ronjonp

  • Needs a day job
  • Posts: 7533
arrrgh layer filters
« Reply #12 on: June 02, 2005, 03:09:17 PM »
The viewport copy isn't too necessary.  I was just wondering if you had added that functionality since the version I have is pretty old.

I could not find the original post with the search option??

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC