gibenner Posted August 13, 2013 Share Posted August 13, 2013 Hello everyone! There are text objects, each figure is a separate object, which has the following order: 1 6 3 4 7 2 5 8 9 The It should be possible procedurally always change it to the following procedure: 1 2 3 4 5 6 7 8 9 I tried to use the sort function on X and Y, but it is not the result that is obtained. Is there a way to sort on two axes at once or is there a simpler solution? It's probably obvious, but I do not see it) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 13, 2013 Share Posted August 13, 2013 Did you try this ? (setq l '(4 7 8 2 1 6 3 5 9)) (vl-sort l '<) Quote Link to comment Share on other sites More sharing options...
gibenner Posted August 13, 2013 Author Share Posted August 13, 2013 No, it does not have to do with the list, but with an object) Here's a picture. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 13, 2013 Share Posted August 13, 2013 You need to account for the insertion points and text strings all together . Quote Link to comment Share on other sites More sharing options...
wimal Posted August 14, 2013 Share Posted August 14, 2013 Did you try this ? (setq l [b][color=red]'[/color][/b](4 7 8 2 1 6 3 5 9)) (vl-sort l [b][color=red]'[/color][/b]<) What is the differance (setq l (4 7 8 2 1 6 3 5 9)) (vl-sort l <) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 14, 2013 Share Posted August 14, 2013 What is the differance (setq l (4 7 8 2 1 6 3 5 9)) (vl-sort l <) You need to read about the quote function to know the differences between these two situations . Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 14, 2013 Share Posted August 14, 2013 What is the difference See this explanation. Quote Link to comment Share on other sites More sharing options...
Commandobill Posted August 14, 2013 Share Posted August 14, 2013 This was kind of fun... What you need to keep in mind is that, in your drawing, it appears that your '1' is below '2&6' and your '9' is below your '8' so the order in which my program will sort will take hat into account and it wont look right as it sorts from upper left to lower right. I'm sure you can take it and mess around with it to fit your needs though (defun c:ArrangeText ( / textSS textList sortedTextList sortedPointList) (vl-load-com) (if (setq textSS (ssget "x" (list (cons 0 "TEXT")(cons 410 "Model")))) (progn (setq textList (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex textSS))))) (setq sortedTextList (vl-sort textList '(lambda (x y) (< (atoi (vla-get-Textstring x)) (atoi (vla-get-Textstring y)))))) (setq sortedPointList (SortPoints (mapcar '(lambda (x) (vlax-get x "InsertionPoint")) textlist))) (mapcar '(lambda (x y) (vlax-put x "InsertionPoint" y)) sortedTextList sortedPointList) )) ) (defun SortPoints ( l ) (setq l (vl-sort l '(lambda (x y) (cond ((= (cadr x)(cadr y)) (< (car x)(car y))) ((> (cadr x)(cadr y))) ) ) ) ) ) Quote Link to comment Share on other sites More sharing options...
gibenner Posted August 14, 2013 Author Share Posted August 14, 2013 Thank you guys for responding! In fact of the matter is that will not be known in advance the position of text in different cases, it can be located in different ways. This is the whole problem and have a predictable outcome. I see the script may try to add it by yourself. Quote Link to comment Share on other sites More sharing options...
Commandobill Posted August 14, 2013 Share Posted August 14, 2013 Thank you guys for responding! In fact of the matter is that will not be known in advance the position of text in different cases, it can be located in different ways. This is the whole problem and have a predictable outcome. I see the script may try to add it by yourself. You can try to add some "fuzz" in the code so that if the text is slightly lower than the other it will still count as in line. Also, I tested it on different alignments, and it doesn't seem to work on all alignments, someone else may be able to explain why... Quote Link to comment Share on other sites More sharing options...
wimal Posted August 14, 2013 Share Posted August 14, 2013 See this explanation. Thanks Mr.Lee Mac I got the idea now. 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.