Jump to content

Search in a layer list


Sweety

Recommended Posts

Hello GUYS. :)

 

How can I search for informations that are related to a layer in Layer List ?

 

Example .......

 

(setq txt (getstring "\n Enter Descriptions to look for it :" T ))	 
    (tblsearch "LAYER" ............................

 

Hope to hear from you all very soon.

 

My Kind emotions

Link to comment
Share on other sites

How can I search for informations that are related to a layer in Layer List ?

 

 

Perhaps this will yield the result(s) you want:

 

(if (and (setq lay (getstring T "\n Enter Layer Name: "))
        (setq layList (tblsearch "LAYER" lay)))
 (setq result ([color=blue]cdr[/color] ([color=blue]assoc[/color] [i][color=red]<Index>[/color][/i] layList))))

Link to comment
Share on other sites

Perhaps this will yield the result(s) you want:

(if (and (setq lay (getstring T "\n Enter Layer Name: "))
        (setq layList (tblsearch "LAYER" lay)))
 (setq result ([color=blue]cdr[/color] ([color=blue]assoc[/color] [i][color=red]<Index>[/color][/i] layList))))

 

Thank you so much

 

You have changed my sentence of the first getstring function, although it's asking about a descriptions of any layer that might be included in a Layer.

 

Take a look please once again ...

(setq txt (getstring "\n Enter [b][color="red"]Descriptions[/color][/b] to look for it :" T ))	 
    (tblsearch "LAYER" ............................

 

Thanks a lot, hope you have the answer for it.

Link to comment
Share on other sites

I do not understand what you are trying to do... you want to enter part of a layer description, then search for what layer it belongs to? :?

Link to comment
Share on other sites

Thamks Renderman for your kind interests.

 

I want to search for a Layer or Layers according to the descriptions that they related to.

 

So I would give the Descriptions details and codes would indicate to a specific layer.

 

Best regards

Link to comment
Share on other sites

I want to search for a Layer or Layers according to the descriptions that they related to.

 

So I would give the Descriptions details and codes would indicate to a specific layer.

 

 

If you already know the layer description, then you already know what layer it is, no?

 

This could just come down to an issue of internal/external layer naming conventions.

Link to comment
Share on other sites

If you already know the layer description, then you already know what layer it is, no?

I want to look for a Layer because I do not know which layer belong to a specific description . ( I have so many layers including Descriptions).

 

Thanks

Link to comment
Share on other sites

I'm sure someone else has a brilliant solution, but for now, perhaps this will help:

 

(defun c:FOO  (/ txt desc hits)
 (vl-load-com)
 (if (setq txt (strcase (getstring "\n Enter Descriptions to look for it :")))
   (progn
     (vlax-for lay  (vla-get-layers
                      (vla-get-activedocument
                        (vlax-get-acad-object)))
       (if (vl-string-search
             txt
             (strcase (setq desc (vla-get-description lay))))
         (cond
           (hits
            (setq hits (append hits
                               (cons (vla-get-name lay) desc))))
           ((setq hits (list (cons (vla-get-name lay) desc)))))))
     (if hits
       (progn
         (textpage)
         (terpri)
         (prompt "\n  >>  Listing Possible Results... ")
         (foreach item  hits
           (prompt (strcat "\n\t\t** Layer Name = \""
                           (car item)
                           "\"\t** Description = \""
                           (cdr item)
                           "\"")))
         (terpri))
       (prompt "\n  <!>  No Results Found  <!> "))))
 (princ))

 

 

Note - In order for me to search the layer description(s) I needed to change the txt variable to only accept a single word. Accepting multiple words makes thing more complicated than I am willing to put into this.

 

Hope this helps!

Link to comment
Share on other sites

Hi

 

This was my attempt, though I think RenderMan's is more suitable

 

(defun filterLayersByDescription (<pattern> / layerCollection tempLIst)

 (setq layerCollection (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))

 (vlax-for <layer> layerCollection
   (if
     (wcmatch
(vla-get-description <layer>)
<pattern>
)
     (setq tempLIst (append tempLIst (list (vla-get-name <layer>))))))
 tempLIst
 )


;Layers that have no description
(filterLayersByDescription "")
;Return a layers that have a description
(filterLayersByDescription "~")

;Return a layers that begin with T
(filterLayersByDescription "T*")

 

Filters would be case sensitive but the routine could be modified to suit

Link to comment
Share on other sites

This was my attempt, though I think RenderMan's is more suitable

 

 

That is very kind of you to say.

 

Many experienced developers prefer functions with argument dependencies. In this case I *assumed* that the user may find entering a simple command preferable.

 

The main difference between the two is the usage of vl-string-search vs. wcmatch. With wcmatch you need to add the wildcards, whereas vl-string-search does not.

 

Overall, good job Jammie. :)

Link to comment
Share on other sites

I'm sure someone else has a brilliant solution, but for now, perhaps this will help:

(defun c:FOO  (/ txt desc hits)
 (vl-load-com)
 (if (setq txt (strcase (getstring "\n Enter Descriptions to look for it :")))
   (progn
     (vlax-for lay  (vla-get-layers
                      (vla-get-activedocument
                        (vlax-get-acad-object)))
       (if (vl-string-search
             txt
             (strcase (setq desc (vla-get-description lay))))
         (cond
           (hits
            (setq hits (append hits
                               (cons (vla-get-name lay) desc))))
           ((setq hits (list (cons (vla-get-name lay) desc)))))))
     (if hits
       (progn
         (textpage)
         (terpri)
         (prompt "\n  >>  Listing Possible Results... ")
         (foreach item  hits
           (prompt (strcat "\n\t\t** Layer Name = \""
                           (car item)
                           "\"\t** Description = \""
                           (cdr item)
                           "\"")))
         (terpri))
       (prompt "\n  <!>  No Results Found  <!> "))))
 (princ))

Note - In order for me to search the layer description(s) I needed to change the txt variable to only accept a single word. Accepting multiple words makes thing more complicated than I am willing to put into this.

 

Hope this helps!

 

A very great work Mr. RENDERMAN. and a very kind of you to do all for me.

 

You are really great.

 

Thank you soooooooo much.

Link to comment
Share on other sites

Hi

This was my attempt, though I think RenderMan's is more suitable

(defun filterLayersByDescription (<pattern> / layerCollection tempLIst)
 (setq layerCollection (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))
 (vlax-for <layer> layerCollection
   (if
     (wcmatch
(vla-get-description <layer>)
<pattern>
)
     (setq tempLIst (append tempLIst (list (vla-get-name <layer>))))))
 tempLIst
 )
;Layers that have no description
(filterLayersByDescription "")
;Return a layers that have a description
(filterLayersByDescription "~")
;Return a layers that begin with T
(filterLayersByDescription "T*")

Filters would be case sensitive but the routine could be modified to suit

 

Wonderful coolection of codes Jammie.

 

Greatly appreciated.

 

Thank you sooooooooooooo much

Link to comment
Share on other sites

A very great work Mr. RENDERMAN. and a very kind of you to do all for me.

 

You are really great.

 

Thank you soooooooo much.

 

Ehh, I was bored :roll: ... you're welcome. :) lol

Link to comment
Share on other sites

In Vanilla :D

 

(defun SearchLayerDescription ( pattern / def l n )
 ;; © Lee Mac 2010
 (reverse
   (while
     (setq def
       (tblnext "LAYER"
         (null def)
       )
     )
     (foreach entry
       (cdadr
         (assoc -3
           (entget
             (tblobjname "LAYER"
               (setq n
                 (cdr
                   (assoc 2 def)
                 )
               )
             )
             '("AcAecLayerStandard")
           )
         )
       )
       (if
         (and (= 1000 (car entry))
           (wcmatch (cdr entry) pattern)
           (not (member n l))
         )
         (setq l (cons n l))
       )
     )
     l
   )
 )
)

Link to comment
Share on other sites

 

Overall, good job Jammie. :)

 

Thanks for that! Trying expand my knowledge of Visual Lisp so learned something new today

 

Regards

 

Jammie

Link to comment
Share on other sites

Wonderful coolection of codes Jammie.

 

Greatly appreciated.

 

Thank you sooooooooooooo much

 

Not a bother glad to help

 

Happy coding

 

Regards

 

Jammie

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