maahee Posted April 14 Posted April 14 (edited) ;;;;;;;;;;;;;;;;;;;;;;;code above (setq ps '((2398.08 1991.12 0.0) (2399.02 1992.25 0.0) (2398.11 1991.16 0.0 2398.08 1991.12 0.0) (2398.14 1991.12 0.0) (2399.06 1992.22 0.0 2399.09 1992.26 0.0))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;nested list convert into non-nested list (defun LM:nest-list (ps) (if ps (if(atom ps) (list ps) (setq k (append (LM:nest-list (car ps)) (LM:nest-list (cdr ps)))));;;;;reference from lee )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;nested list convert into point list (setq pl '()) (setq u 0) (repeat (/ (length k) 3) (setq r (nth u k)) (setq r1 (nth (+ u 1) k)) (setq pl (reverse (cons (list r r1) pl))) (setq u (+ u 3)) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;point sort by distance min to max (setq m '(2398.0882 1991.0917)) :referance point which use find the distsnce point is constant. ; Initialize distances list (setq dists (list)) ; Calculate the distances from the reference point to each check point (foreach a pl (setq dists (cons (distance m a) dists)) ) (setq maxDist (apply 'max dists)) (setq mP (nth (vl-position maxDist dists) pl)) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sort fourth and fifth point tobe use for next activity can't convert nested list to point list Edited April 14 by maahee Quote
Emmanuel Delay Posted April 14 Posted April 14 (edited) Looking at that code... you have the function LM:nest-list, which I suppose is originally LM:flatten. But anyway, you only have the function definition defun, you never actually invoke the function. I rewrote the code a little in such a way that the function is invoked. See if this helps you further. (defun c:test ( / ps k pl u r r1 m dists maxDist mP) ;;;;;;;;;;;;;;;;;;;;;;;code above (setq ps '((2398.08 1991.12 0.0) (2399.02 1992.25 0.0) (2398.11 1991.16 0.0 2398.08 1991.12 0.0) (2398.14 1991.12 0.0) (2399.06 1992.22 0.0 2399.09 1992.26 0.0))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;nested list convert into non-nested list ;; https://www.lee-mac.com/flatten.html ;; Flatten List - Lee Mac ;; Transforms a nested list into a non-nested list (defun LM:flatten ( l ) (if (atom l) (list l) (append (LM:flatten (car l)) (if (cdr l) (LM:flatten (cdr l)))) ) ) (setq k (LM:flatten ps )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;nested list convert into point list (setq pl '()) (setq u 0) (repeat (/ (length k) 3) (setq r (nth u k)) (setq r1 (nth (+ u 1) k)) (setq pl (reverse (cons (list r r1) pl))) (setq u (+ u 3)) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;point sort by distance min to max (setq m '(2398.0882 1991.0917)) ;; :referance point which use find the distsnce point is constant. ; Initialize distances list (setq dists (list)) ; Calculate the distances from the reference point to each check point (foreach a pl (setq dists (cons (distance m a) dists)) ) (setq maxDist (apply 'max dists)) (setq mP (nth (vl-position maxDist dists) pl)) ;; print results: (princ "\n") (princ mP) (princ ) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sort fourth and fifth point tobe use for next activity ... Edited April 14 by Emmanuel Delay 1 Quote
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.