devitg Posted October 30, 2017 Share Posted October 30, 2017 Say impossible is not true . Who can do , solve it , Wonder full. Thanks ROY_043 Quote Link to comment Share on other sites More sharing options...
Grrr Posted October 30, 2017 Share Posted October 30, 2017 Nicely done Roy! Your ObjectListGroupByBox might help here. Quote Link to comment Share on other sites More sharing options...
Raje Posted October 31, 2017 Author Share Posted October 31, 2017 Right. Plus there is a bigger problem with my code in post #17: non-integer texts should be filtered out as well. very happy with your code.:) sample file works well. and some times getting not found error. please test with my file. thank you very much...:) Test File.dwg Quote Link to comment Share on other sites More sharing options...
Raje Posted October 31, 2017 Author Share Posted October 31, 2017 Not winning any speed tests , but here's another one: working good, but takes time while executing on more texts. its ok.. thank you for your participation. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted October 31, 2017 Share Posted October 31, 2017 @ronjonp: Using the IntersectWith method is a good idea. It is more accurate than my bounding box approach for rotated texts. @Grrr: For rectangular polylines the function may indeed be useful. But not for more complex polylines. @Raje: I am not getting a 'not found error' with that last dwg. But I do notice that the line portion of underlined texts is not taken into account for the bounding box. Note: I use BricsCAD. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted October 31, 2017 Share Posted October 31, 2017 @ronjonp: Isn't this code risky when s is not an "_X" selection set?: (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) In some cases the return value can contain the same ename multiple times. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 31, 2017 Share Posted October 31, 2017 @ronjonp:Isn't this code risky when s is not an "_X" selection set?: (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) In some cases the return value can contain the same ename multiple times. I've never seen this behavior? Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted October 31, 2017 Share Posted October 31, 2017 I've never seen this behavior?Must be something wrong with my memory. Disregard my previous post. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 31, 2017 Share Posted October 31, 2017 very happy with your code.:) sample file works well. and some times getting not found error. please test with my file. thank you very much...:) So many times code is written to clean up messes. How was this mess created in the first place? Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 31, 2017 Share Posted October 31, 2017 Must be something wrong with my memory. Disregard my previous post. No worries. Happens to the best of us Quote Link to comment Share on other sites More sharing options...
Raje Posted November 1, 2017 Author Share Posted November 1, 2017 Thank Roy..with help of your code saving my time. Quote Link to comment Share on other sites More sharing options...
Raje Posted November 1, 2017 Author Share Posted November 1, 2017 Thank you, ronjonp.. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted November 1, 2017 Share Posted November 1, 2017 Thank you, ronjonp.. Glad to help. If you have very large drawings, it may help speed to select portions rather than doing all at once. I updated my code a bit to hopefully improve sped a little bit. Quote Link to comment Share on other sites More sharing options...
Raje Posted November 1, 2017 Author Share Posted November 1, 2017 Thank you very much.. ronjonp Quote Link to comment Share on other sites More sharing options...
symoin Posted January 13, 2019 Share Posted January 13, 2019 On 10/30/2017 at 10:56 PM, ronjonp said: Not winning any speed tests , but here's another one: (defun c:foo (/ a l s s2 tmp) (defun _foo (str / i tmp) (setq i (vl-string->list ".0123456789")) (if (setq tmp (vl-remove-if-not '(lambda (x) (vl-position x i)) (vl-string->list str))) (atof (apply 'strcat (mapcar 'chr tmp))) ) ) (if (setq s (ssget ":L" '((0 . "text")))) (progn (foreach x (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))) (if (setq tmp (_foo (vla-get-textstring x))) (setq s2 (cons (cons tmp x) s2)) ) ) (setq s (vl-sort s2 (function (lambda (a b) (> (car a) (car b)))))) (while (setq a (car s)) (if (setq l (vl-remove-if-not (function (lambda (x) (vlax-invoke (cdr a) 'intersectwith (cdr x) acextendnone))) (setq s (cdr s)) ) ) (progn (while (setq tmp (vl-some (function (lambda (x) (vl-remove-if-not (function (lambda (y) (vlax-invoke (cdr y) 'intersectwith (cdr x) acextendnone)) ) (vl-remove-if (function (lambda (z) (vl-position z l))) s) ) ) ) l ) ) (setq l (cons (car tmp) l)) ) (mapcar (function (lambda (x) (setq s (vl-remove x s)) (vla-delete (cdr x)))) l) (vla-put-color (cdr a) 1) (vla-update (cdr a)) ) ) ) ) ) (princ) ) (vl-load-com) What if the texts are not overlapping, but within a small distances. Example to get the max from the set of 3 or 4 texts selected and so if there are many such locations can the command be repeated with a while t. Quote Link to comment Share on other sites More sharing options...
symoin Posted January 13, 2019 Share Posted January 13, 2019 On 10/30/2017 at 4:37 AM, BIGAL said: Try this no checking for text matching or smarter handling of numbers. (defun c:max-min ( / ss mylist obj biggest smallest inspt) (alert "Press <Cr> to exit loop") (while (setq ss (ssget (list (cons 0 "Text")))) (setq mylist '()) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1))))) (setq mylist (cons (vla-get-textstring obj) mylist)) (setq inspt (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint obj)))) ) (setq biggest (rtos (apply 'max (mapcar 'atof mylist))2 3)) (setq smallest (rtos (apply 'min (mapcar 'atof mylist))2 3)) ;(alert (strcat "The biggest is ... " biggest "\n\nThe smallest is ... " smallest)) (command "Text"(getpoint "pick text point") "" "" biggest) ) ) Dear Bigal, can you post your original code with erase; and also can it take multiple sets with a given distances between the texts and placing the max at its original location with zero degree text rotation. 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.