Tharwat Posted January 4, 2013 Share Posted January 4, 2013 Interesting approach Tharwat, Watch out for duplicates(ish) , and sometimes gives strange results It does when you have texts not in order . Quote Link to comment Share on other sites More sharing options...
irneb Posted January 4, 2013 Share Posted January 4, 2013 Wow, splitting the list into two sets makes more sense. I stopped using entmod for string modification ever since ADESK introduced Annotative Text StylesYou'll note Lee's code is not using entmod on the entire DXF list. He's only sending the ename & text string items (codes -1 and 1) - so the issue with annotative text does not happen due to no change on the height code 40. Quote Link to comment Share on other sites More sharing options...
irneb Posted January 4, 2013 Share Posted January 4, 2013 Bloody stupid of me sorry . Here's a fix for my code: (defun c:SortTxt3 (/ sym ss eLst sLst) (vl-load-com) (initget "Ascending Descending") (setq sym (cond ((eq (getkword "\nChoose [Ascending/Descending] <Ascending>: ") "Descending") (cons <= <=)) (t (cons <= >=)))) (if (ssget "_:L" '((0 . "TEXT"))) (progn (vlax-for eo (setq ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))) (setq eLst (cons eo eLst) sLst (cons (vla-get-TextString eo) sLst))) (vla-Delete ss) (mapcar 'vla-put-TextString (vl-sort eLst '(lambda (eo1 eo2) ((cdr sym) (cadr (vlax-get eo1 'InsertionPoint)) (cadr (vlax-get eo2 'InsertionPoint))))) (vl-sort sLst '(lambda (s1 s2) ((car sym) (strcase s1) (strcase s2))))))) (princ)) Reduced the ('s by taking a leaf from Lee's code Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted January 4, 2013 Share Posted January 4, 2013 Thanks all, it was a fun challenge. 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.