layerfilter

layerfilter

Anonymous
Not applicable
461 Views
10 Replies
Message 1 of 11

layerfilter

Anonymous
Not applicable
I can create with LISP a new layer filter if there is one before
I can't create a first layer filter with LISP
Is it possible to create the first layer filter with VBA ?

--
-------------------------------------------
Didier Duhem
d.duhem@wanadoo.fr
http://perso.wanadoo.fr/didier.duhem/
-------------------------------------------
0 Likes
462 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
"Didier DUHEM" wrote in message
news:3C245A92.DBC6B068@wanadoo.fr...
> I can create with LISP a new layer filter if there is one before
> I can't create a first layer filter with LISP
> Is it possible to create the first layer filter with VBA ?
>

You can't do this with VBA alone, because it requires
you to add a child dictionary object to the extension
dictionary attached to the Layers collection. If there
are no layer filters defined, then the dictionary object
that holds them does not exist, and must be created, but
unfortunately the AcadDictionary class does not provide
any way to add child dictionary objects. You can hack it
by using the (dictxxxx) functions in LISP (although they
may not be available in all circumstances).

Another way to solve the problem is to get a copy of
AcadX.arx (www.caddzone.com/acad/acadx.htm), which has
an AddDictionary() method on the Application object,
that can create dictionaries that are children of other
dictionaries.

The following code shows how to use AddDictionary() to
do this:

'-----------------------------------------------------------

Public Function GetLayerFilters(Database As AcadDatabase) As AcadDictionary
Const KeyName = "ACAD_LAYERFILTERS"
Dim Layers As AcadLayers
Dim XDictionary As AcadDictionary
Dim Filters As AcadDictionary
Set Layers = Database.Layers
Set XDictionary = Layers.GetExtensionDictionary
On Error Resume Next
Set Filters = XDictionary(KeyName)
If Err Then
Err.Clear
Dim AcadX As New AcadXApplication
Set Filters = AcadX.AddDictionary(XDictionary, KeyName)
End If
Set GetLayerFilters = Filters
End Function

Public Sub Test()
Dim Filters As AcadDictionary
Set Filters = GetLayerFilters(ThisDrawing.Database)
ThisDrawing.Utility.Prompt "There are " & _
Filters.Count " & layer filters defined"
End Sub

'-----------------------------------------------------------
0 Likes
Message 3 of 11

Anonymous
Not applicable
Attached is a module demonstrating how to create layer filters
with VBA. Let me know if you have any questions.

--
Good judgment comes from experience.
Experience comes from bad judgment.

http://www.acadx.com


"Didier DUHEM" wrote in message
news:3C245A92.DBC6B068@wanadoo.fr...
> I can create with LISP a new layer filter if there is one
before
> I can't create a first layer filter with LISP
> Is it possible to create the first layer filter with VBA ?
>
> --
> -------------------------------------------
> Didier Duhem
> d.duhem@wanadoo.fr
> http://perso.wanadoo.fr/didier.duhem/
> -------------------------------------------
>
>
0 Likes
Message 4 of 11

Anonymous
Not applicable
Oops! My code forces you to choose between layer states (e.g. On
or Off but not both). Sorry about that. I'll rework it a little
later tonight but I'm sure you won't have any problem fixing the
problem yourself in case I don't get to it quickly enough.

--
Good judgment comes from experience.
Experience comes from bad judgment.

http://www.acadx.com
0 Likes
Message 5 of 11

Anonymous
Not applicable
Does this code require a certain release of
AutoCAD or a patch?

On AutoCAD 2000, i get this error:

"AcRxClassName entry is not in the system registry"

The only reason I tried your code was because
I remember having this same error when I tried
to add a child dictionary object to another
dictionary. I just could not get it to work no
matter what i tried.

Seth
0 Likes
Message 6 of 11

Anonymous
Not applicable
> Does this code require a certain
> release of AutoCAD or a patch?

I've only tested it on AutoCAD 2002, so I can't say one way or
the other. Perhaps someone else in this group can help us
determine the source of your problem.

--
Good judgment comes from experience.
Experience comes from bad judgment.

http://www.acadx.com


"SethD" wrote in message
news:f0a5338.3@WebX.maYIadrTaRb...
Does this code require a certain release of
AutoCAD or a patch?
On AutoCAD 2000, i get this error:
"AcRxClassName entry is not in the system registry"
The only reason I tried your code was because
I remember having this same error when I tried
to add a child dictionary object to another
dictionary. I just could not get it to work no
matter what i tried.
Seth
0 Likes
Message 7 of 11

Anonymous
Not applicable
I tested the code on AutoCAD 2000 after reading your post. I
don't what service pack I have installed, if any, but it worked
just fine.

--
Good judgment comes from experience.
Experience comes from bad judgment.

http://www.acadx.com
0 Likes
Message 8 of 11

Anonymous
Not applicable
If you tested the code on AutoCAD 2000, can
you tell me if you have (or had) any other
AutoCAD based products (MAP, ADT, etc)
installed on that same system?

Seth
0 Likes
Message 9 of 11

Anonymous
Not applicable
I have AutoCAD 2000 and MDT6 installed on this machine

--
Good judgment comes from experience.
Experience comes from bad judgment.

http://www.acadx.com


"SethD" wrote in message
news:f0a5338.6@WebX.maYIadrTaRb...
If you tested the code on AutoCAD 2000, can
you tell me if you have (or had) any other
AutoCAD based products (MAP, ADT, etc)
installed on that same system?
Seth
0 Likes
Message 10 of 11

Anonymous
Not applicable
AddObject() will not add dictionary objects on AutoCAD 2000,
because A2K fails to install some required registry entries.
That is why you are getting that error message.

If you have any other AutoCAD based product on the same system,
and the problem is corrected in that product, then installing
it will also correct the problem in any copy of AutoCAD 2000
or later that is installed on the same machine.

The reason I use the AddDictionary() method in AcadX.arx
is because I need a reliable way to add child dictionaries
on any installation of AutoCAD 2000 or higher, regardless
of whether the registry fix is present on the target system
or not.

I don't have a list of the registry entries that AutoCAD
2000 fails to install, but another way around the problem
is to add them yourself.

"SethD" wrote in message
news:f0a5338.6@WebX.maYIadrTaRb...
> If you tested the code on AutoCAD 2000, can
> you tell me if you have (or had) any other
> AutoCAD based products (MAP, ADT, etc)
> installed on that same system?
> Seth
>
>
0 Likes
Message 11 of 11

Anonymous
Not applicable
> I don't have a list of the registry entries that AutoCAD
> 2000 fails to install, but another way around the problem
> is to add them yourself.

Does anyone besides Tony know what these are?
0 Likes