Jump to content

list layer filters autolisp


svorgodne

Recommended Posts

Is it possible to get a list from all layer filters within a drawing through autolisp?

 

So far I can create them by:

 

(command
 "._-layer"
 "_filter"
 "_new"
 "_group"
 ""
 "0*"
 "0"
 "s"
 "All"
 ""
)

 

but I cannot get the list from them

Link to comment
Share on other sites

If I understand you clearly try this :-

(defun layerlist (/ a b)
 (if (setq a (tblnext "layer" t))
   (while a
     (setq b (cons (cdr (assoc 2 a)) b)
    a (tblnext "layer")
     )
   )
 )
 (reverse b)
)

Link to comment
Share on other sites

Here is a starting point

 


(dictsearch (vlax-vla-object->ename
       (vla-GetExtensionDictionary
         (vla-get-layers
           (vla-get-activedocument
             (vlax-get-acad-object)
	   )
         )
       )
     )
     
"ACAD_LAYERFILTERS"
)

 

 

And some more stuff you'll probably be interested in here: http://www.cadtutor.net/forum/showthread.php?61032-Layer-Properties-Filters

Link to comment
Share on other sites

Thank you both... I think I didn't make myself clear enough. What I need is a

 

Layer Filter List

 

not only a Layer List

 

This is what I mean...

 

attachment.php?attachmentid=56912&cid=1&stc=1

 

Thanks in any case. I'll keep on looking for a solution in the meantime.

 

svorgodne

LayerFilterList.jpg

Link to comment
Share on other sites

This is the result when I paste the function directly to the textscr

 

(-1 . )

(0 . "DICTIONARY")

(5 . "45B8")

(102 . "{ACAD_REACTORS")

(330 . )

(102 . "}")

(330 . )

(100 . "AcDbDictionary")

(280 . 0)

(281 . 1)

 

Am I doing something wrong? Am I supposed to get the Fiter names from the layers?

 

Thanks again. I'll keep on trying. At least I solve it by resetting everytime the filters although this is not precisely what I want. I want to apply only the missing filters and not all of them.

 

Svorgodne

Link to comment
Share on other sites

Consider the following function to list all Layer Group Filters:

(defun LM:grouplayerfilters nil
   (   (lambda ( foo ) (foo (entget (cdr (assoc 330 (entget (tblobjname "layer" "0")))))))
       (lambda ( enx / dic itm rtn )
           (and (setq dic (cdr (assoc 360 (member '(102 . "{ACAD_XDICTIONARY") enx))))
                (setq dic (cdr (assoc -1  (dictsearch dic "aclydictionary"))))
                (while (setq itm (dictnext dic (not itm)))
                    (if (= "AcLyLayerGroup" (cdr (assoc 1 itm)))
                        (setq rtn (cons (cons (cdr (assoc 300 itm)) (foo itm)) rtn))
                    )
                )
           )
           (reverse rtn)
       )
   )
)

Since Group Filters may be nested, if your drawing were to contain Layer Group Filters in the following structure:

 

layergroupfilters.png

 

The above function would return the following:

_$ (LM:grouplayerfilters)
(("Group Filter1" ("Group Filter4") ("Group Filter5")) ("Group Filter2" ("Group Filter6")) ("Group Filter3"))

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...