Tony,
I tried your program on a selection of text entities and it returned a "null
function". Now I am just a LISP hacker and maybe I dont understand the program
completly. The program as I understand it, goes thru each of the text entities in
the selection and adds a number that is equals the sorted order. ( i hope that
made sense). Any help would be appreciated!
Thanks,
Paul
Tony Tanzillo wrote:
> Apparently, Frank does not understand how to do multiple-
> key sorting. The code he posted does not sort on the X and
> Y ordinate of any point.
>
> Rather, it merely sorts on the distance from the specified
> point to the lower-left corner of the extents box containing
> all of the text in the selection set, which I'm sure is not
> what you meant by "in order of on X,Y coordinates". 🙂
>
> The code I posted is designed to allow you to define how
> the sort works, and what key(s) are used. Using it to sort
> on the X and Y of a point is very easy to do.
>
> This example uses the same functions from my prior post,
> except that it sorts the left-aligned text first on the
> X, and then on the Y component of each insertion point:
>
> (setq epsilon 1.0e-6)
>
> ;; Using this as the comparison function passed
> ;; to (ss-index) will sort the text first on Y
> ;; component of the insertion poing, and then on
> ;; the X component of same:
>
> (defun compare-points (p1 p2)
> (if (equal (cadr p1) (cadr p2) epsilon)
> (< (car p1) (car p2))
> (< (cadr p1) (cadr p2))
> )
> )
>
> (defun C:TEST ( / ss indices oldtext)
> (setq ss (ssget '((0 . "TEXT"))))
> (setq indices
> (ss-index ss
> '(lambda (ename)
> (cdr (assoc 10 (entget ename))) ;; cache entire point
> ) ;; as sort key
> 'compare-points ;; comparison function
> )
> )
> (setq j -1)
> (foreach i indices
> (setq e (ssname ss i))
> (setq oldtext (cdr (assoc 1 (entget e))))
> (entmod
> (list
> (cons -1 e)
> (cons 1
> (strcat
> oldtext
> " ( "
> (itoa (setq j (1+ j)))
> " ) "
> )
> )
> )
> )
> )
> )
>
> Dan Elkins wrote:
> >
> > Does any body have a LISP routine that will take a selection set and re-sort
> > it in order of x,y coordinates.
> >
> > Dan
> > A2K
>
> --
> /*********************************************************/
> /* Tony Tanzillo Design Automation Consulting */
> /* Programming & Customization for AutoCAD & Compatibles */
> /* ----------------------------------------------------- */
> /* tony.tanzillo@worldnet.att.net */
> /* http://ourworld.compuserve.com/homepages/tonyt */
> /*********************************************************/
--
Stock & Associates Consulting Engineers, Inc. reserves all copyright rights, but
grants a temporary license to the recipient to use the materials contained in the
attached computer data file for use in development of recipient's work associated
with this project. Stock & Associates Consulting Engineers, Inc. does not warrant
the accuracy of any information contained on said data file. Stock & Associates
Consulting Engineers, Inc. assumes no liability for unauthorized alterations and
alterations to the information contained herein.