; Related thread (SS->SortedMatrixL) :
; https://www.cadtutor.net/forum/topic/63343-switching-two-items-in-a-table-in-autocad-lisp/?tab=comments#comment-522608
; Sum Numbers in Exploded Table
; http://www.theswamp.org/index.php?topic=55258.0
(defun C:test
( / mapncar mysort LM:UniqueFuzz SS
->SortedMatrixL M
-Text
) ; Map to the nth level items - Lee Mac :
; (mysort (lambda (a b) (apply '< (mapcar 'car (list a b)))) pL)
;; Unique with Fuzz - Lee Mac
;; Returns a list with all elements considered duplicate to a given tolerance removed.
(defun LM:UniqueFuzz
( l f
/ x r
) )
; 1. Prompt for a selection
; 2. Create Assoc List of (InsertionPoint Vla-Object)
; 3. Redefine the Assoc List - by grouping the items by X (each group is sorted by Y)
; 4. Sort the Whole Assoc List by X
; 5. Obtain the vla-objects from the assoc list
(lambda ( fuzz
/ SS i o L tmpL rtn
) ( (and (princ "\nSelect Text-Cells from Exploded Table: ") (setq SS
(ssget "_:L-I" '
((0 .
"*TEXT"))))) ); repeat
); and
); foreach
(and rtn
; rtn - List Of Lists of (InsertionPoint Vla-Object) (setq rtn
(mapncar
1 '
(lambda (x
) (cadr x
)) rtn
)) ; Obtain only the objects ; ??? ); and
rtn ; Result should be Assoc list of vla-objects, where each item defines a row, i.e.: '((o1 o2 o3) (o4 o5 o6) (o7 o8 o9))
); SS
); cond
); lambda
); setq SS->SortedMatrixL
)
( ; Main
L
)
)
)
)
)
)
)
); mapncar
(M-Text
)
)
)
); foreach
); and
); lambda
)
); defun