rlx Posted August 8, 2018 Posted August 8, 2018 I notice that wildcart search is not always the ultimate way to go since it call unrelevant layers. I need a toggle to be able to search the whole word or wildcard. How can it be done? guess whole word search can have 2 situations , word is the first word so it would end with a space , or it is the last word , so it would begin with a space. e.g. "walls and windows" (or "walls_and_windows") or "windows_and_walls". Your filter would be *walls* for any match , "walls *" for any line beginning with walls or "* walls" for strings ending with walls. Quote
samifox Posted August 8, 2018 Author Posted August 8, 2018 guess whole word search can have 2 situations , word is the first word so it would end with a space , or it is the last word , so it would begin with a space.e.g. "walls and windows" (or "walls_and_windows") or "windows_and_walls". Your filter would be *walls* for any match , "walls *" for any line beginning with walls or "* walls" for strings ending with walls. from my tests this search crateria is not always welcome, im not looking for general layers names but specific names i know my client always use. so "parking roof" is not relevant but "roof" is the wildcard is needed when the xref has been bind, in this situation it layer name will include the prefix of the file Quote
rlx Posted August 8, 2018 Posted August 8, 2018 (defun c:samifox ( / doc fn fp s p l o n c wc) (vl-load-com) (setq doc (vla-get-activedocument (vlax-get-acad-object)) fn (findfile "map.txt")) (princ "\nPress space bar to include wildcard or any other key or button for none") (if (equal (grread) '(2 32)) (setq wc "*")(setq wc "")) (cond ((null fn)(princ "\nData file map.txt not found")) ((not (setq fp (open fn "r")))(princ "\nUnable to read from map.txt")) (t (while (setq s (read-line fp)) (if (setq p (vl-string-position (ascii ",") s)) (setq l (cons (cons (substr s 1 p) (substr s (+ 2 p))) l)))) (if (vl-consp l) (vlax-for o (vla-get-layers doc) (setq n (strcase (vla-get-name o))) (if (vl-some '(lambda (x) (if (wcmatch n (strcase (strcat wc (car x) wc))) (setq c (cdr x)))) l) (vl-catch-all-apply 'vla-put-color (list o c)))))) ) (princ) ) Quote
samifox Posted August 8, 2018 Author Posted August 8, 2018 (defun c:samifox ( / doc fn fp s p l o n c wc) (vl-load-com) (setq doc (vla-get-activedocument (vlax-get-acad-object)) fn (findfile "map.txt")) (princ "\nPress space bar to include wildcard or any other key or button for none") (if (equal (grread) '(2 32)) (setq wc "*")(setq wc "")) (cond ((null fn)(princ "\nData file map.txt not found")) ((not (setq fp (open fn "r")))(princ "\nUnable to read from map.txt")) (t (while (setq s (read-line fp)) (if (setq p (vl-string-position (ascii ",") s)) (setq l (cons (cons (substr s 1 p) (substr s (+ 2 p))) l)))) (if (vl-consp l) (vlax-for o (vla-get-layers doc) (setq n (strcase (vla-get-name o))) (if (vl-some '(lambda (x) (if (wcmatch n (strcase (strcat wc (car x) wc))) (setq c (cdr x)))) l) (vl-catch-all-apply 'vla-put-color (list o c)))))) ) (princ) ) thanks ive used space bar but it doesnt work Quote
samifox Posted August 8, 2018 Author Posted August 8, 2018 (defun c:samifox ( / doc fn fp s p l o n c wc) (vl-load-com) (setq doc (vla-get-activedocument (vlax-get-acad-object)) fn (findfile "map.txt")) (princ "\nPress space bar to include wildcard or any other key or button for none") (if (equal (grread) '(2 32)) (setq wc "*")(setq wc "")) (cond ((null fn)(princ "\nData file map.txt not found")) ((not (setq fp (open fn "r")))(princ "\nUnable to read from map.txt")) (t (while (setq s (read-line fp)) (if (setq p (vl-string-position (ascii ",") s)) (setq l (cons (cons (substr s 1 p) (substr s (+ 2 p))) l)))) (if (vl-consp l) (vlax-for o (vla-get-layers doc) (setq n (strcase (vla-get-name o))) (if (vl-some '(lambda (x) (if (wcmatch n (strcase (strcat wc (car x) wc))) (setq c (cdr x)))) l) (vl-catch-all-apply 'vla-put-color (list o c)))))) ) (princ) ) sorry ive read the wrong file its working perfect thanks you!!! Quote
rlx Posted August 8, 2018 Posted August 8, 2018 sorry ive read the wrong fileits working perfect thanks you!!! one appie for you and one air mile for me Quote
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.