Sweety Posted October 19, 2010 Share Posted October 19, 2010 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 Quote Link to comment Share on other sites More sharing options...
Lt Dan's legs Posted October 19, 2010 Share Posted October 19, 2010 ...are you looking for wcmatch Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 19, 2010 Share Posted October 19, 2010 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)))) Quote Link to comment Share on other sites More sharing options...
Sweety Posted October 19, 2010 Author Share Posted October 19, 2010 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. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 19, 2010 Share Posted October 19, 2010 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? Quote Link to comment Share on other sites More sharing options...
Sweety Posted October 19, 2010 Author Share Posted October 19, 2010 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 Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 19, 2010 Share Posted October 19, 2010 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. Quote Link to comment Share on other sites More sharing options...
Sweety Posted October 19, 2010 Author Share Posted October 19, 2010 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 Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 19, 2010 Share Posted October 19, 2010 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! Quote Link to comment Share on other sites More sharing options...
jammie Posted October 19, 2010 Share Posted October 19, 2010 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 Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 19, 2010 Share Posted October 19, 2010 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. Quote Link to comment Share on other sites More sharing options...
Sweety Posted October 19, 2010 Author Share Posted October 19, 2010 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. Quote Link to comment Share on other sites More sharing options...
Sweety Posted October 19, 2010 Author Share Posted October 19, 2010 HiThis 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 Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 19, 2010 Share Posted October 19, 2010 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 ... you're welcome. lol Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 19, 2010 Share Posted October 19, 2010 In Vanilla (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 ) ) ) Quote Link to comment Share on other sites More sharing options...
Sweety Posted October 19, 2010 Author Share Posted October 19, 2010 Thanks Lee. I would try it . Thank you so much. Quote Link to comment Share on other sites More sharing options...
jammie Posted October 19, 2010 Share Posted October 19, 2010 Overall, good job Jammie. Thanks for that! Trying expand my knowledge of Visual Lisp so learned something new today Regards Jammie Quote Link to comment Share on other sites More sharing options...
jammie Posted October 19, 2010 Share Posted October 19, 2010 Wonderful coolection of codes Jammie. Greatly appreciated. Thank you sooooooooooooo much Not a bother glad to help Happy coding Regards Jammie Quote Link to comment Share on other sites More sharing options...
BlackBox Posted October 19, 2010 Share Posted October 19, 2010 Trying expand my knowledge of Visual Lisp ... Welcome to 'the pack'. :wolf: Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 19, 2010 Share Posted October 19, 2010 ... Welcome to 'the pack'. :wolf:Buzz's girlfriend...WOOF! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.