ronjonp Posted August 4, 2021 Posted August 4, 2021 38 minutes ago, robierzo said: Hello. In the end I have succeeded. This is what I was looking for. I have included a margin of tolerance so that it eliminates the points that do not fulfill a minimum distance. I have used ronjonp's statement "(vlax-put obj 'coordinates (apply 'append nuevalista_pt))", and I have solved it. Thank you very much to all. (defun c:elptlw () (setq margen_error 0.005) (setq nuevalista_pt nil) (setq ent (car(entsel"\nSelecciona lwpolyline: "))) (setq obj (vlax-ename->vla-object ent)) (setq lista_ent (entget ent)) ;lista_puntos lwpolyline (foreach elemento_n lista_ent (cond ((=(car elemento_n) 10) (if (null (member t (mapcar '(lambda (pt) (< (distance (cdr elemento_n) pt) margen_error)) nuevalista_pt ))) (setq nuevalista_pt (cons (cdr elemento_n) nuevalista_pt)) ) ) ) );fin Foreach (setq nuevalista_pt (reverse nuevalista_pt)) (vlax-put obj 'coordinates (apply 'append nuevalista_pt)) ) Glad you got it sorted. FWIW, you should localize your variables in you code like so: (defun c:elptlw ( / ELEMENTO_N ENT LISTA_ENT MARGEN_ERROR NUEVALISTA_PT OBJ PT) 1 Quote
confutatis Posted August 4, 2021 Posted August 4, 2021 (edited) ...although there is still the problem of bulges, but congratulations to ronjonp for being able to synthesize a not easy code Edited August 4, 2021 by confutatis 1 Quote
confutatis Posted August 5, 2021 Posted August 5, 2021 Just as a workout for me, you can use recursive mode to find double vertices. The remove_doubles function is not mine. (defun c:elptlw (/ remove_doubles ent) (defun remove_doubles (lst) (if lst (cons (car lst) (remove_doubles (vl-remove (car lst) lst)))) );;; not mine (setq ent (car(entsel"\nSelecciona lwpolyline: "))) (vlax-put (vlax-ename->vla-object ent) 'coordinates (apply 'append (reverse (remove_doubles (mapcar 'cdr (vl-remove-if-not '(lambda (elem) (= (car elem) 10)) (entget ent))))) ) ) (princ) ) 1 Quote
robierzo Posted August 5, 2021 Author Posted August 5, 2021 Thank you very much confutatis. It's great. 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.