Jump to content

Accessing all of the layers in a document


harrison-matt

Recommended Posts

All,

 

I am wondering how to access all of the layers in a document using either Vlisp or DXF if possible. I am trying to grab layers that fit a particular string with wildcards and i need a list of all layers in the doc to do soo. Any suggestions?

 

Thanks,

Matt

Link to comment
Share on other sites

Well,

 

I have figured it out:

(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for lay (vla-get-Layers doc)(setq layers (cons (vla-get-name lay) layers)))
(setq laylist (acad_strlsort layers))

 

But now i am lost..... I am trying to filter a particular string from the list into another list: the string is "G-ANNO-REVC-" in one list and "G-ANNO-REVD-" in another list... any thoughts?

 

Matt

Link to comment
Share on other sites

Right Wild Card Match, I still need to filter the list...

I could figure this out if i take enough time.... if i had enough time...

Link to comment
Share on other sites

Here is what i have, the wcmatch is still new to me, how can the return T be of use...

 

(vl-load-com)
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for lay (vla-get-Layers doc)(setq layers (cons (vla-get-name lay) layers)))
(setq laylist (acad_strlsort layers))
(foreach name laylist (wcmatch name "G-ANNO-REV*"))

 

Please i am in need of educating in regards to both foreach and wcmatch.

 

Matt

Link to comment
Share on other sites

hmmm....

how about a list of "T" and "nil" for each wcmatch...

(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for lay (vla-get-Layers doc)
 (setq layers (cons (vla-get-name lay) layers)))

(setq Tlist (mapcar '(lambda (name)
        (wcmatch name "G-ANNO-REV*"))
     Layers))

 

I am brain dead.... but i'll keep pondering please HELP!

 

Thanks,

 

Matt

Link to comment
Share on other sites

Here is what it is that i am tyring to create from this list.

 

The list of layers that is created is going to be used for a pop up list in DCL I will use that selection to pass arguments to turn on/off/isolate/invert isolate the selected element from the list. I just need the dang list to build the rest of the dialog. I can get a list of all the layers... Maybe not the most effective but hey its a list! And now i need to filter that list just to contain items that are wcmatches of G-ANNO-REV*.

 

Matt

Link to comment
Share on other sites

one way...

(vlax-for Lyrs (vla-get-Layers (vla-get-activedocument (vlax-get-acad-object)))
 (setq lst
    (if
      (wcmatch (strcase (vla-get-name Lyrs)) (strcase "G-anno*"))
  (cons
    (vla-get-name Lyrs) lst)
      )
   )
 (setq laylst (acad_strlsort lst))
)

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...