Jump to content

Recommended Posts

Posted
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)

 

  • Thanks 1
Posted (edited)

...although there is still the problem of bulges, but congratulations to ronjonp for being able to synthesize a not easy code

Edited by confutatis
  • Like 1
Posted

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)
)

 

  • Like 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...