Author Topic: BricsCAD - Make Layer Filters  (Read 3579 times)

0 Members and 1 Guest are viewing this topic.

danallen

  • Guest
BricsCAD - Make Layer Filters
« on: October 03, 2013, 12:11:28 AM »
In AutoCAD 2005 this code work to create layer filters, but not in BricsCAD. Does anyone have a solution?

(Code was modified to not crash in BricsCAD per tip from roy_043

Code - Auto/Visual Lisp: [Select]
  1.     ;;; From: "GaryDF" <arch_prog...@hotmail.com>
  2.     ;;; Newsgroups: autodesk.autocad.customization
  3.     ;;; References: <3788944.1106770311821.JavaMail.jive@jiveforum1.autodesk.com>
  4.     ;;; Subject: Re: need lisp to CREATE layer filters
  5.     ;;; Date: Thu, 27 Jan 2005 08:28:08 -0600
  6.     ;;; Posted by Elise Moss
  7.     ;;; ON/OFF
  8.     ;;;  On 1
  9.     ;;;  Off 3
  10.     ;;; FREEZE/THAW
  11.     ;;;  Freeze 4
  12.     ;;;  Thaw 12
  13.     ;;; CURRENT VPORT
  14.     ;;;  Freeze 16
  15.     ;;;  Thaw 48
  16.     ;;; NEW VPORT
  17.     ;;;  Freeze 64
  18.     ;;;  Thaw 192
  19.     ;;; LOCK/UNLOCK
  20.     ;;;  Lock 256
  21.     ;;;  UnLock 768
  22.     ;;; PLOT
  23.     ;;;  Plot 1024
  24.     ;;;  Don't Plot 3072
  25.  
  26.     (defun-q ABC_CreateLayerFilter (filtlst /  lfiltobj safecode safefilt)
  27.       (vl-load-com)
  28.       (setq LFILTOBJ (vla-addobject
  29.                        (vla-GetExtensionDictionary
  30.                          (vla-Get-Layers
  31.                            (vla-Get-ActiveDocument
  32.                              (vlax-Get-Acad-Object)
  33.                            )
  34.                          )
  35.                        )
  36.                        "ACAD_LAYERFILTERS"
  37.                        "AcDbDictionary"
  38.                      )
  39.             SAFECODE (vlax-make-safearray 2 '(0 . 6))
  40.             SAFEFILT (vlax-make-safearray 12 '(0 . 6))
  41.       )
  42.       (vlax-safearray-fill SAFECODE (list 1 1 1 1 70 1 1))
  43.       (foreach
  44.              SUBLST FILTLST
  45.         (vlax-safearray-fill
  46.           SAFEFILT
  47.           (mapcar '(lambda (X) (vlax-make-variant X)) SUBLST)
  48.         )
  49.         (vla-addxrecord LFILTOBJ (nth 0 SUBLST))
  50.         (vla-setxrecorddata
  51.           (vla-item LFILTOBJ (nth 0 SUBLST))
  52.           SAFECODE
  53.           SAFEFILT
  54.         )
  55.       )
  56.       (prin1)
  57.     )
  58.     (defun c:MakeFilters ( / filtlst)
  59.       (setq filtlst
  60.         (list   ;;name          Lay     col     lt      flags   lw      plot
  61.           (list "ABC-On"                "*"     "*"     "*"     "1"     "*"     "*")
  62.           (list "ABC-OnFrozen"          "*"     "*"     "*"     "5"     "*"     "*")
  63.           (list "ABC-OnThawed"          "*"     "*"     "*"     "13"    "*"     "*")
  64.           (list "ABC-Thawed"            "*"     "*"     "*"     "12"    "*"     "*")
  65.           (list "ABC-Off"               "*"     "*"     "*"     "3"     "*"     "*")
  66.           (list "ABC-OffFrozen" "*"     "*"     "*"     "7"     "*"     "*")
  67.           (list "ABC-OffThawed" "*"     "*"     "*"     "15"    "*"     "*")
  68.           (list "ABC-Frozen"            "*"     "*"     "*"     "4"     "*"     "*")
  69.           (list "ABC-Xref-Only" "*|*"   "*"     "*"     "0"     "*"     "*")
  70.           (list "ABC-Xref-Not"          "~*|*"  "*"     "*"     "0"     "*"     "*")
  71.           (list "ABC-Xref-Bound"        "*$#$*" "*"     "*"     "0"     "*"     "*")
  72.           (list "ABC-Xref-BoundNot"     "~*$#$*""*"     "*"     "0"     "*"     "*")
  73.         )
  74.       )
  75.       (ABC_CreateLayerFilter filtlst)
  76.     )
  77.  

Vaidas

  • Newt
  • Posts: 66
Re: BricsCAD - Make Layer Filters
« Reply #1 on: October 03, 2013, 06:33:17 AM »
It works on my machine. Which version of BricsCAD do you run?
(mapcar 'chr '(107 105 116 111 120 46 99 111 109))

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: BricsCAD - Make Layer Filters
« Reply #2 on: October 03, 2013, 06:54:38 AM »
There are two systems of storing layer filters. The code uses the 'old' (< AC2005) "ACAD_LAYERFILTERS" system. The 'new' sytem uses a different dictionary: "ACLYDICTIONARY" and a different format for the filters.

The code works OK but BricsCAD only displays 'old' style filters if there are no 'new' style filters in the drawing. Note: editing a single 'old' style layer filter means that all filters are automatically translated to the 'new' system.

I'll try to come up with a solution.

danallen

  • Guest
Re: BricsCAD - Make Layer Filters
« Reply #3 on: October 03, 2013, 12:02:32 PM »
It works on my machine. Which version of BricsCAD do you run?

we're on v13

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: BricsCAD - Make Layer Filters
« Reply #4 on: October 04, 2013, 10:12:36 AM »
Code: [Select]
;;; ======================================================================
;;; BKG_LayerFilter: Some functions for processing layer filters.
;;; ======================================================================
;;; Author:       Roy Klein Gebbinck (www.b-k-g.nl)
;;; Made for:     http://www.theswamp.org/index.php?topic=45420.0
;;; Version:      20131004: First release.
;;; Remarks:      The function (BKG_LayerFilter_DataConvertSingle) does
;;;               not process the plotstyle.
;;; ======================================================================
;;; USE AT YOUR OWN RISK.
;;; ======================================================================

Available functions:
Code: [Select]
BKG_LayerFilter_LayersExtDictionaryGet
BKG_LayerFilter_LayersExtDictionaryGetOrMake
BKG_LayerFilter_XrecordDataGet
BKG_LayerFilter_XrecordDataSet
BKG_LayerFilter_DataConvertSingle
BKG_LayerFilter_Merge
BKG_LayerFilter_DeleteAll
BKG_LayerFilter_DeleteSome
BKG_LayerFilter_Make
c:TestFilterMake_OldStyle
c:TestFilterMake_NewStyle

BricsCAD V13 has a problem with the (VP) plotstyle in layer filters so I have left that out.
Comments are of course welcome.
« Last Edit: October 04, 2013, 10:32:17 AM by roy_043 »

Yure_Brics

  • Mosquito
  • Posts: 1
Re: BricsCAD - Make Layer Filters
« Reply #5 on: May 02, 2023, 01:42:58 AM »
Hi guys, I'm quite new here.

I would like to know if anyone can help me with one lisp. Currently, I'm working with very heavy files (10,000 layers or more) and I can't purge them because they are part of a system here. So my solution is to set the Layer Filter Control to "All Used Layers". I was wondering if is possible to do that through a lisp or even better, add this command to be loaded with the software?

My Bricscad version:
Version 14.2.17 (x64) revision 35160

Thanks
Cheers

danAllen

  • Newt
  • Posts: 133
Re: BricsCAD - Make Layer Filters
« Reply #6 on: May 02, 2023, 11:56:54 AM »
I have Bricscad V15, but I don't have a direct answer. I use the BKG routines to delete all existing layer filters that don't start with company prefix, then create company standard filters. It seems the last filter created is the active on the layer dialog/filter, which for me is non xref layer names "~*|*". I skimmed the code but couldn't see where it was "activated". Perhaps it is just a function of creation. But the "used" status doesn't seem to be an option for creation of layer filters in Briscad layer dialog, nor lisp.

So my only suggestion is that if it would work for you to set a lisp created layer filter active, try the BKG routines Roy posted.