Author Topic: How can i exclude XREF in layer filters  (Read 5892 times)

0 Members and 1 Guest are viewing this topic.

MvdP

  • Guest
How can i exclude XREF in layer filters
« on: January 19, 2011, 11:52:46 AM »
I have found this lisp here on the Swamp  to create layer filters.All layer filters are created so that part working.

But here is our issue we are having.

All our comany layers are starting with  0,1,2,3,4,5,6,7,8 and 9
All our xref's  start with a four number digit. (company project number)
Lets say a xref start with 1909 what_so_ever.dwg it is displayed in layer filer group 10
Lets say a xref start with 2002 what_so_ever.dwg it is displayed in layer filer group 20
Lets say a xref start with 3525 what_so_ever.dwg it is displayed in layer filer group 30
We only want to see the layers from current drawing in the specific layer filter and non off the xref layers

Is this possible .?


Code: [Select]
; MLF.lsp
; December 2010  (The swamp.org)
;====================================================================================================
(defun c:MLF(/ FILTLST LFILTOBJ SAFECODE SAFEFILT)
  (vl-load-com)
  (setq FILTLST  (list
                   ;;name   Lay col   lt  flags lw   plot
                   (list "Group_00" "0*" "*" "*" 0 "*" "*")
                   (list "Group_10" "1*" "*" "*" 0 "*" "*")
                   (list "Group_20" "2*" "*" "*" 0 "*" "*")
                   (list "Group_30" "3*" "*" "*" 0 "*" "*")
                   (list "Group_40" "4*" "*" "*" 0 "*" "*")
                   (list "Group_50" "5*" "*" "*" 0 "*" "*")
                   (list "Group_60" "6*" "*" "*" 0 "*" "*")
                   (list "Group_70" "7*" "*" "*" 0 "*" "*")
                   (list "Group_80" "8*" "*" "*" 0 "*" "*")
                   (list "Group_90" "9*" "*" "*" 0 "*" "*")
                  
                 )
        LFILTOBJ (vla-addobject
                   (vla-GetExtensionDictionary
                     (vla-Get-Layers
                       (vla-Get-ActiveDocument
                         (vlax-Get-Acad-Object)
                       )
                     )
                   )
                   "ACAD_LAYERFILTERS"
                   "AcDbDictionary"
                 )
        SAFECODE (vlax-make-safearray 2 '(0 . 6))
        SAFEFILT (vlax-make-safearray 12 '(0 . 6))
  )
  (vlax-safearray-fill SAFECODE (list 1 1 1 1 70 1 1))
  (foreach
         SUBLST FILTLST
    (vlax-safearray-fill
      SAFEFILT
      (mapcar '(lambda (X) (vlax-make-variant X 8)) SUBLST)
    )
    (vla-addxrecord LFILTOBJ (nth 0 SUBLST))
    (vla-setxrecorddata
      (vla-item LFILTOBJ (nth 0 SUBLST))
      SAFECODE
      SAFEFILT
    )
  )
  (princ)
  (princ "\nAll Layer Filters have been created.")
  (princ)
)



Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: How can i exclude XREF in layer filters
« Reply #1 on: January 19, 2011, 12:24:33 PM »
Might want to take a look at this little gem.  :-)

http://www.theswamp.org/index.php?topic=12640.msg154978#msg154978
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How can i exclude XREF in layer filters
« Reply #2 on: January 19, 2011, 01:30:43 PM »
If this "and non off the xref layers" = "and none of the xref layers" then all you do is add "~*|*,1*" to your name filter.

Using Michael's code:

Code: [Select]
(defun c:mlf (/ dict xdict lst x)
  (setq xdict (vlax-vla-object->ename
(vla-getextensiondictionary
  (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
)
      )
  )
  (setq
    dict (if (setq dict (dictsearch xdict "ACAD_LAYERFILTERS"))
   (cdr (assoc -1 dict))
   (dictadd xdict
    "ACAD_LAYERFILTERS"
    (entmakex '((0 . "dictionary") (100 . "AcDbDictionary") (280 . 0) (281 . 1)))
   )
)
  )
  (foreach x '(;;name       Lay col lt  flags lw  plot
       ("Group_00" "~*|*,0*" "*" "*" 0 "*" "*")
       ("Group_10" "~*|*,1*" "*" "*" 0 "*" "*")
       ("Group_20" "~*|*,2*" "*" "*" 0 "*" "*")
       ("Group_30" "~*|*,3*" "*" "*" 0 "*" "*")
       ("Group_40" "~*|*,4*" "*" "*" 0 "*" "*")
       ("Group_50" "~*|*,5*" "*" "*" 0 "*" "*")
       ("Group_60" "~*|*,6*" "*" "*" 0 "*" "*")
       ("Group_70" "~*|*,7*" "*" "*" 0 "*" "*")
       ("Group_80" "~*|*,8*" "*" "*" 0 "*" "*")
       ("Group_90" "~*|*,9*" "*" "*" 0 "*" "*")
      )
    (dictadd dict
     (car x)
     (entmakex (list '(0 . "xrecord")
     '(100 . "AcDbXrecord")
     '(280 . 1)
     (cons 1 (car x))
     (cons 1 (cadr x))
     (cons 1 (caddr x))
     (cons 1 (nth 3 x))
     (cons 70 (nth 4 x))
     (cons 1 (nth 5 x))
     (cons 1 (nth 6 x))
       )
     )
    )
  )
  (princ)
)
(c:mlf)
« Last Edit: January 19, 2011, 01:45:03 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MvdP

  • Guest
Re: How can i exclude XREF in layer filters
« Reply #3 on: January 20, 2011, 01:34:23 PM »

When use this
Code: [Select]
("Group_10" "~*|*,1*" "*" "*" 0 "*" "*")
  and load an xref starting with an 1  and make that group active all layers are shown (layers in current drawing and all from xref) in the layer manager

ronjonp

  • Needs a day job
  • Posts: 7529
Re: How can i exclude XREF in layer filters
« Reply #4 on: January 20, 2011, 08:14:10 PM »
Hmmm you're right ... guess I should have tested it out  :-D

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC