Missing layers at created layer filter

Missing layers at created layer filter

Sandervp
Advocate Advocate
1,415 Views
6 Replies
Message 1 of 7

Missing layers at created layer filter

Sandervp
Advocate
Advocate

Hello everybody,

 

A while ago, I asked something about creating a layer filter (see Layer filter). The problem was solved but I do have a problem again, it could be because I'm using this lisp for the first time at AutoCad 2017.

 

I have some layers which doesn't appear in a group filter.

My lisp does create several filters. Properties filters for all the layers in a drawing but also group and properties filters for all the layers which aren't part of the external references.

 

I do have 70 layers at my current drawing. If I look to the filter for all the layers, I see 70 layers. That's correct. Also if I look to the properties filter of the "Xref-not" filter, 65 layers are visible (the 5 missing layers are from the xref)

 

But if I look to the group filter at the "xref-not" filter, 49 layers appear... Not the 65 layers.

 

For example:

 

At the properties filter, the layers called WL5501--" and "WL5501--_D" are visible. But if I look to the group filter (created with  "(Command "-layer" "filter" "n" "g" "Lagen" "*55*" "" "55 - GKW" "")" I only see the layer "WL5501--" and the "WL5501--_D" layer isn't visible.

 

Why?

 

Thank you for your help.

 

This is the lisp which I'm using:

 

(defun c:XREFNOT ( / xdict dict xrecname )
 (vl-load-com)
    (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)
                    )
                )
            )
        )
    )
    
    (princ
        (if (dictsearch dict (setq xrecname "No_Xref_Layers"))
            (strcat
                "Layer filter named <"
                xrecname
                "> already exists."
            )
            (if
                (dictadd dict xrecname
                    (entmakex
                        (append
                           '(
                                (0 . "xrecord")
                                (100 . "AcDbXrecord")
                                (280 . 1)
                            )    
                            (list (cons 1 xrecname))
                           '(
                                (1 . "~*|*")
                                (1 . "*")
                                (1 . "*")
                                (70 . 0)
                                (1 . "*")
                                (1 . "*")
                                (-3          
                                    (   "ACAD"
                                        (1000 . "( NAME== \"~*|*\" )")
                                    )         
                                )
                            )    
                        )
                    )
                )
                (strcat
                    "Created layer filter named <"
                    xrecname
                    ">."
                )
                
            )    
        )    
    )    
(command ".-layer" "filter" "set" "No_Xref_Layers" "")    

    (princ)    
);_End of defun 
 
 
(Defun C:createfilters () 
     
     (Command "-layer" "filter" "n" "g" "No_Xref_Layers" "**" "Lagen" "")

     (Command "-layer" "filter" "n" "g" "Lagen" "*57*" "" "57 - LUCHT" "")
     (Command "-layer" "filter" "n" "g" "Lagen" "*56*" "" "56 - CV" "")
     (Command "-layer" "filter" "n" "g" "Lagen" "*55*" "" "55 - GKW" "")
     (Command "-layer" "filter" "n" "g" "Lagen" "*54*" "" "54 - GASSEN" "")
     (Command "-layer" "filter" "n" "g" "Lagen" "*53*" "" "53 - WATER" "")
     (Command "-layer" "filter" "n" "g" "Lagen" "*52*" "" "52 - RIOOL" "")
     (Command "-layer" "filter" "n" "g" "Lagen" "*5*" "" "5 - W-INSTALLATIE" "")
     (Command "-layer" "filter" "n" "g" "Lagen" "*WM*" "" "5X - MAATVOERING" "")

     (Command "-layer" "filter" "n" "p" "No_Xref_Layers" "Eigenschappen" "Eigenschappen" "")

     (Command "-layer" "filter" "n" "p" "Eigenschappen" "frozen==\"true\"" "" "frozen" "")
     (Command "-layer" "filter" "n" "p" "Eigenschappen" "off==\"true\"" "" "off" "")
     (Command "-layer" "filter" "n" "p" "Eigenschappen" "off==\"false\" and frozen==\"false\"" "" "on" "")
     (Command "-layer" "filter" "n" "p" "Eigenschappen" "frozen==\"false\"" "" "thawed" "")
     (Command "-layer" "filter" "n" "p" "Eigenschappen" "locked==\"true\"" "" "locked" "")
     (Command "-layer" "filter" "n" "p" "Eigenschappen" "locked==\"false\"" "" "unlocked" "")
     (Command "-layer" "filter" "n" "p" "Eigenschappen" "plottable==\"false\"" "" "no plot" "")

     (Command "-layer" "filter" "n" "p" "" "Eigenschap" "Eigenschap" "")

     (Command "-layer" "filter" "n" "p" "Eigenschap" "frozen==\"true\"" "" "frozen_" "")
     (Command "-layer" "filter" "n" "p" "Eigenschap" "off==\"true\"" "" "off_" "")
     (Command "-layer" "filter" "n" "p" "Eigenschap" "off==\"false\" and frozen==\"false\"" "" "on_" "")
     (Command "-layer" "filter" "n" "p" "Eigenschap" "frozen==\"false\"" "" "thawed_" "")
     (Command "-layer" "filter" "n" "p" "Eigenschap" "locked==\"true\"" "" "locked_" "")
     (Command "-layer" "filter" "n" "p" "Eigenschap" "locked==\"false\"" "" "unlocked_" "")
     (Command "-layer" "filter" "n" "p" "Eigenschap" "plottable==\"false\"" "" "no plot_" "")

(princ)
);_End of defun

(Defun C:ftr ()
     (Command "qsave")
     (c:xrefnot)
     (c:createfilters)

(princ "\n...All layer filters have been created.")
(princ)
)

(notice; "Lagen" and "Eigenschappen" are Dutch for "Layers" and "Properties")

0 Likes
Accepted solutions (1)
1,416 Views
6 Replies
Replies (6)
Message 2 of 7

ВeekeeCZ
Consultant
Consultant

How about post some sample drawing, no object, just layers. Next Time.

 

The issue I see is that you don't understand a difference between "properties filter" and "group". Your "Lagen" filter as **, is a PROPERTIES filter, not a group of specified layers. The same applies for your infrastructure layers - all are properties filters. See the example.

 

properties filter

NAME=="Layer*"

 

group filter

Layer1

Layer2

Layer3

 

If you need to combine "Layer1-5" and a layer with a very different name, say "Water", then use a PROPERTIES filter, NAME=="Layer1*" AND NAME=="Water"

0 Likes
Message 3 of 7

Sandervp
Advocate
Advocate

Hello BeekeeCZ,

 

I have attached a drawing.

Maybe you can see what goes wrong here.

 

By using AutoCad 2016 or an older verion, nothing went wrong. The lisp was working oke. 

0 Likes
Message 4 of 7

ВeekeeCZ
Consultant
Consultant

I have just 2016, it looks like it works.

But I think you're bending the definition over... it's even impossible to see a definition in layer manager.

I have nothing else to suggest, so if you want to try my tip... replace G with P, and see what happens. 🙂

0 Likes
Message 5 of 7

Sandervp
Advocate
Advocate

Hello BeekeeCZ,

 

I've changed the g into a p and if I use the lisp again, after uploading, only the "eigenschap" and "eigenschappen" filters are created. I do not see the other filters.

 

filters.png

0 Likes
Message 6 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution

Hmm, I didn't meant that literally, correct syntax I used in post #2.

 

But I've done the modification for you, so see the spoiler. It still works on my 2016, can't test 2017.

 

Spoiler
(defun c:XREFNOT ( / xdict dict xrecname )
 (vl-load-com)
    (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)
                    )
                )
            )
        )
    )
    
    (princ
        (if (dictsearch dict (setq xrecname "No_Xref_Layers"))
            (strcat
                "Layer filter named <"
                xrecname
                "> already exists."
            )
            (if
                (dictadd dict xrecname
                    (entmakex
                        (append
                           '(
                                (0 . "xrecord")
                                (100 . "AcDbXrecord")
                                (280 . 1)
                            )    
                            (list (cons 1 xrecname))
                           '(
                                (1 . "~*|*")
                                (1 . "*")
                                (1 . "*")
                                (70 . 0)
                                (1 . "*")
                                (1 . "*")
                                (-3          
                                    (   "ACAD"
                                        (1000 . "( NAME== \"~*|*\" )")
                                    )         
                                )
                            )    
                        )
                    )
                )
                (strcat
                    "Created layer filter named <"
                    xrecname
                    ">."
                )
                
            )    
        )    
    )    
(command ".-layer" "filter" "set" "No_Xref_Layers" "")    

    (princ)    
);_End of defun 
 
 
(Defun C:createfilters () 
     
     (Command "-layer" "filter" "n" "p" "No_Xref_Layers" "name==\"*\"" "Lagen" "")

     (Command "-layer" "filter" "n" "p" "Lagen" "name==\"*57*\"" "57 - LUCHT" "")
     (Command "-layer" "filter" "n" "p" "Lagen" "name==\"*56*\"" "56 - CV" "")
     (Command "-layer" "filter" "n" "p" "Lagen" "name==\"*55*\"" "55 - GKW" "")
     (Command "-layer" "filter" "n" "p" "Lagen" "name==\"*54*\"" "54 - GASSEN" "")
     (Command "-layer" "filter" "n" "p" "Lagen" "name==\"*53*\"" "53 - WATER" "")
     (Command "-layer" "filter" "n" "p" "Lagen" "name==\"*52*\"" "52 - RIOOL" "")
     (Command "-layer" "filter" "n" "p" "Lagen" "name==\"*5*\"" "5 - W-INSTALLATIE" "")
     (Command "-layer" "filter" "n" "p" "Lagen" "name==\"*WM*\"" "5X - MAATVOERING" "")

     (Command "-layer" "filter" "n" "p" "No_Xref_Layers" "Eigenschappen" "Eigenschappen" "")

     (Command "-layer" "filter" "n" "p" "Eigenschappen" "frozen==\"true\"" "" "frozen" "")
     (Command "-layer" "filter" "n" "p" "Eigenschappen" "off==\"true\"" "" "off" "")
     (Command "-layer" "filter" "n" "p" "Eigenschappen" "off==\"false\" and frozen==\"false\"" "" "on" "")
     (Command "-layer" "filter" "n" "p" "Eigenschappen" "frozen==\"false\"" "" "thawed" "")
     (Command "-layer" "filter" "n" "p" "Eigenschappen" "locked==\"true\"" "" "locked" "")
     (Command "-layer" "filter" "n" "p" "Eigenschappen" "locked==\"false\"" "" "unlocked" "")
     (Command "-layer" "filter" "n" "p" "Eigenschappen" "plottable==\"false\"" "" "no plot" "")

     (Command "-layer" "filter" "n" "p" "" "Eigenschap" "Eigenschap" "")

     (Command "-layer" "filter" "n" "p" "Eigenschap" "frozen==\"true\"" "" "frozen_" "")
     (Command "-layer" "filter" "n" "p" "Eigenschap" "off==\"true\"" "" "off_" "")
     (Command "-layer" "filter" "n" "p" "Eigenschap" "off==\"false\" and frozen==\"false\"" "" "on_" "")
     (Command "-layer" "filter" "n" "p" "Eigenschap" "frozen==\"false\"" "" "thawed_" "")
     (Command "-layer" "filter" "n" "p" "Eigenschap" "locked==\"true\"" "" "locked_" "")
     (Command "-layer" "filter" "n" "p" "Eigenschap" "locked==\"false\"" "" "unlocked_" "")
     (Command "-layer" "filter" "n" "p" "Eigenschap" "plottable==\"false\"" "" "no plot_" "")

(princ)
);_End of defun

(Defun C:ftr ()
     (Command "qsave")
     (c:xrefnot)
     (c:createfilters)

(princ "\n...All layer filters have been created.")
(princ)
)
Message 7 of 7

Sandervp
Advocate
Advocate

Thank you (again) BeekeeCZ!

 

 

I've changed the code into your code and this part:

 

(Command "-layer" "filter" "n" "p" "No_Xref_Layers" "name==\"*\"" "Lagen" "")

 

has solved the problem!

 

Greetings Sander

0 Likes