@komondormrex
Can't you see that your codes are written in manner that your lines go to much right, so it's very difficult to follow what you've written... If you don't mind, I'll post your code prittyfied manually by me, so that everyone is able to see it easy, at least little better than your original version...
(defun c:meander ( / circle_sset center_list y_coordinate_list unique_y_list 3dpoly_vertices_list )
(or (not (vl-catch-all-error-p (vl-catch-all-apply 'vlax-get-acad-object nil))) (vl-load-com))
(if (setq circle_sset (ssget '((0 . "circle"))))
(progn
(setq center_list (mapcar '(lambda ( circle ) (vlax-get circle 'center)) (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex circle_sset)))))
y_coordinate_list (vl-sort (mapcar 'cadr center_list) '<)
y_fuzz 1
)
(foreach _y y_coordinate_list
(if (not (vl-some '(lambda ( y_unique ) (equal _y y_unique y_fuzz)) unique_y_list)) (setq unique_y_list (append unique_y_list (list _y))))
)
(setq center_list (mapcar '(lambda ( _y ) (vl-remove-if-not '(lambda ( center ) (equal (cadr center) _y y_fuzz)) center_list)) unique_y_list)
center_list
(mapcar
'(lambda ( y_sublist )
(if (zerop (rem (vl-position y_sublist center_list) 2))
(vl-sort y_sublist '(lambda ( center_1 center_2 ) (< (car center_1) (car center_2))))
(vl-sort y_sublist '(lambda ( center_1 center_2 ) (> (car center_1) (car center_2))))
)
)
center_list
)
3dpoly_vertices_list (apply 'append (apply 'append center_list))
)
(vla-add3dpoly (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
(vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 1 (length 3dpoly_vertices_list)))
3dpoly_vertices_list
)
)
)
)
(princ)
)
Marko Ribar, d.i.a. (graduated engineer of architecture)