TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: DanB on November 02, 2005, 02:31:59 PM

Title: Layer Filters "Current"
Post by: DanB on November 02, 2005, 02:31:59 PM
We have 4-5 frequently used company layer filters (AutoCAD 2006, LDD 2006, 3-4 users on Civil 3d 2006). A co-worker made a  request for a Key-in/macro that will set a Filter "current" and apply this to the layer manager pull-down without opening the Layer Manager. We typically have a basemap xref that has numerous layers that must be scanned (slowly) as the Layer Manager opens. How does one go about accessing the layer filters that are defined in the drawing through LISP? I think with a push in the right direction I can do the rest of it (I hope) myself. Hints? Ideas?

Thanks in advance,
Dan
Title: Re: Layer Filters "Current"
Post by: Bob Wahr on November 02, 2005, 02:45:09 PM
push (http://www.theswamp.org/forum/index.php?topic=2760.0)
Title: Re: Layer Filters "Current"
Post by: DanB on November 02, 2005, 03:27:49 PM
If you are referring to:

Code: [Select]
(defun C:LayerFiltersDelete ()
 (vl-Load-Com)
 (vl-Catch-All-Apply
   '(lambda ()
      (vla-Remove (vla-GetExtensionDictionary
                    (vla-Get-Layers
                      (vla-Get-ActiveDocument
                        (vlax-Get-Acad-Object))))
        "ACAD_LAYERFILTERS")))
 (princ "\nAll layer filters have been deleted.")
 (princ)
)

I don't believe AutoCAD 2006 stores the filter information as it did in older versions. The above routine no longer deletes filters in my drawing.
Title: Re: Layer Filters "Current"
Post by: Bob Wahr on November 02, 2005, 03:36:09 PM
*shrug*  I know jack about lisp but you might try
Code: [Select]
(defun C:LayerFiltersDelete ()
(vl-Load-Com)
(vl-Catch-All-Apply
   '(lambda ()
      (vla-Remove (vla-GetExtensionDictionary
                    (vla-Get-Layers
                      (vla-Get-ActiveDocument
                        (vlax-Get-Acad-Object))))
        "ACLYDICTIONARY")))
(princ "\nAll layer filters have been deleted.")
(princ)
)

Hadn't thought about it but between r15 and r16 it switched from ACAD_LAYERFILTERS to ACLYDICTIONARY

Title: Re: Layer Filters "Current"
Post by: CarlB on November 02, 2005, 05:38:14 PM
Robert Bell's "LFD" modified to work in 2005 & 2006 , with wildcards, should give you something to work with.

http://discussion.autodesk.com/servlet/JiveServlet/download/130-335314-3861685-30875/LayerFiltersDelete.lsp
Title: Re: Layer Filters "Current"
Post by: T.Willey on November 02, 2005, 05:48:09 PM
I have not yet seen anything that will let you set a layer filter current.  I have seen other post asking the question in other forumns, but none have had an answer of how to do it.  Sorry.

Tim
Title: Re: Layer Filters "Current"
Post by: whdjr on November 03, 2005, 10:11:46 AM
You may have to go the command route:

Code: [Select]
(command "-lman" "restore" "putyourlayerstatehere" "")
coded blindly - hope it works
Title: Re: Layer Filters "Current"
Post by: Bob Wahr on November 03, 2005, 10:59:35 AM
Layer state and layer filter are two different animals.
Title: Re: Layer Filters "Current"
Post by: David Hall on November 03, 2005, 12:09:31 PM
To the best of my knowledge, the layer filters are not exposed to Lisp or VBA.  I have tried to get filters in code, and was denied both times.  Maybe 2006 / 2007 has it
Title: Re: Layer Filters "Current"
Post by: Bob Wahr on November 03, 2005, 12:24:46 PM
Maybe 2006
Nope
/ 2007 has it
If Adesk decides to listen.
Title: Re: Layer Filters "Current"
Post by: DanB on November 03, 2005, 12:28:33 PM
I think this task is either beyond my LISPing capabilities or is just not feasible. Thanks all for the replies/comments. Ii do check in from time to time, so if any new discoveries are made for accessing Layer filters please share.
Title: Re: Layer Filters "Current"
Post by: Bob Wahr on November 03, 2005, 12:32:25 PM
I didn't want to discourage you by telling you that you couldn't do it.  Heck, there was a chance that you would trip over something that everyone else had missed.  Then you would be legendary.  You would be the hero of literally tens of people.
Title: Re: Layer Filters "Current"
Post by: MP on November 03, 2005, 12:35:37 PM
Am I missing something here? Aren't layer filters just an entry in an extension dictionary attached to the layers collection?

Quote
====================================Object====================================

<IAcadLayers2 2130144272>

==================================Properties==================================

_NewEnum                 <IUnknown>
Application              <IAcadApplication>
Count                    10
Database                 <IAcadDatabase>
Document                 <IAcadDocument>
Handle                   2
HasExtensionDictionary   :vlax-true
ObjectID                 2130144272
ObjectName               AcDbLayerTable
OwnerID                  0

===================================Methods====================================

Add
Delete
Erase
GenerateUsageData
GetExtensionDictionary
GetXdata
Item
SetXdata

===============================DXF Group Codes================================

-1    <Entity name: 7ef76c10>
0     TABLE
2     LAYER
5     2
102   {ACAD_XDICTIONARY
360   <Entity name: 7ef76ee0>
102   }
330   <Entity name: 0>
100   AcDbSymbolTable
70    10

Quote
====================================Object====================================

<IAcadDictionary 2130144992>

==================================Properties==================================

_NewEnum                 <IUnknown>
Application              <IAcadApplication>
Count                    2
Database                 <IAcadDatabase>
Document                 <IAcadDocument>
Handle                   94
HasExtensionDictionary   :vlax-false
Name                     <Null Object, Reference or Value>
ObjectID                 2130144992
ObjectName               AcDbDictionary
OwnerID                  2130144272

===================================Methods====================================

AddObject
AddXRecord
Delete
Erase
GetExtensionDictionary
GetName
GetObject
GetXdata
Item
Remove
Rename
Replace
SetXdata

===============================DXF Group Codes================================

-1    <Entity name: 7ef76ee0>
0     DICTIONARY
330   <Entity name: 7ef76c10>
5     94
100   AcDbDictionary
280   1
281   1
3     ACAD_LAYERFILTERS
360   <Entity name: 7ef76ef0>
3     ACLYDICTIONARY
360   <Entity name: 7ef76ee8>

Quote
====================================Object====================================

<IAcadDictionary 2130145008> (1/2 of <IAcadDictionary 2130144992>)

==================================Properties==================================

_NewEnum                 <IUnknown>
Application              <IAcadApplication>
Count                    0
Database                 <IAcadDatabase>
Document                 <IAcadDocument>
Handle                   96
HasExtensionDictionary   :vlax-false
Name                     ACAD_LAYERFILTERS
ObjectID                 2130145008
ObjectName               AcDbDictionary
OwnerID                  2130144992

===================================Methods====================================

AddObject
AddXRecord
Delete
Erase
GetExtensionDictionary
GetName
GetObject
GetXdata
Item
Remove
Rename
Replace
SetXdata

===============================DXF Group Codes================================

-1    <Entity name: 7ef76ef0>
0     DICTIONARY
5     96
102   {ACAD_REACTORS
330   <Entity name: 7ef76ee0>
102   }
330   <Entity name: 7ef76ee0>
100   AcDbDictionary
280   0
281   1
Title: Re: Layer Filters "Current"
Post by: Jeff_M on November 03, 2005, 12:45:14 PM
Michael, correct you are. However, I have not seen anyone be able to set which one the Layer dialogue uses. Therein lies the problem.......
Title: Re: Layer Filters "Current"
Post by: MP on November 03, 2005, 12:46:00 PM
Ahhh, thanks for lighting the candle Jeff.

:)