• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

removal of double points

  • Thread starter Thread starter tizianost
  • Start date Start date

tizianost

Guest
Hello everyone, I'm trying in my third script in lisp and as usual I'm stuck, I hope you can help me.

with the code below I would like to delete from a given design all "point" objects overlapped, I know that there is a similar function in the express menu but I would like a script that functions on any autocad even without such menu.


(setq group (ssget "x")); select all elements of the design
(setq nent (1- (sslength group)));
(setq i 1); prevents endless cycles
(while (and (> nent -1) (< i 1000000) ; cycle for all elements
(setq ent) ; extracts the name of the element
(seq element (entget ent)); extracts the "ent" element from the database
;(print i)
(setq tipoent (cdr (assoc 0 element)))
(print tipoent)

(if)
(progn)
(setq nent2 nent)
(setq j 0)
(while (and (> nent2 -1) (< j 1000000)
(setq ent2 (sname group nent2) ; extracts the name of the element
(setq element2 (entget ent2) ; extracts the "ent" element from the database


(if (/= (cdr (assoc -1 element)) (cdr(assoc -1 element2))) ; verify that it is not the same object)
(progn)
(print (cdr (assoc -1 element))
(print (cdr (assoc -1 element2))
(setq coordinate1 (cdr (assoc 10 element)))
(setq coordinate2 (cdr 10 element2))

(if (= coordinate1 coordinates2) ; if the second object has the same coordinates as the first...(progn)
(entry)
(print "eliminate")
(setq group (ssget "x")) ; replenish all the elements of the design
(setq nent (1- (sslength group)));
) ;
(progn)
(print "object with different coorinate")
(print (car coordinates1))
(print (car coordinate2))
) ;
) ;
) ;
) ;

(setq j (1+ j)
(setq nent2 (1- nent2)
) ; end of while
) ;
) ;

(setq i (1+ i))
(setq nent (1- nent))

) ; end of while


after endless attempts have come to believe that errors lie in the functions if they fail to compare the lists of coordinates and entities (I'm wrong)

Thank you in advance
Hi.
Titian
 
Cosine confrontal coordinates:
(and (= (car pt1) (car pt2)) (= (cr pt1) (cd pt2)) (= (cd pt1) (cd pt2))

bye
 
(if (= coordinates 1 coordinates 2)) ; has an extra bracket

so that the values can be verified you must use the method of rpor66 or write the code:
(if)equal coordinates1 coordinate2

so doing the lisp turns, but deletes all points as it does always check on the same point (every point is clearly equal to itself), you must then change:
(setq nent2 nent)
in
(setq nent2 (1- nent))so it should work:
HTML:
(setq group (ssget "x")); select all elements of the design
(setq nent (1- (sslength group)));
(setq i 1); prevents endless cycles
(while (and (> nent -1) (< i 1000000)
; cycle for all elements
(setq ent) ; extracts the name of the element
(seq element (entget ent)); extracts the "ent" element from the database
;(print i)
(setq tipoent (cdr (assoc 0 element)))
(print tipoent)

(if)
(progn)
(setq nent2 (1- nent)
(setq j 0)
(while (and (> nent2 -1) (< j 1000000)
(setq ent2 (sname group nent2) ; extracts the name of the element
(setq element2 (entget ent2) ; extracts the "ent" element from the database

(if (/= (cdr (assoc -1 element))
(cdr (assoc -1 element2)
) ; verify that it is not the same object
(progn)
(print (cdr (assoc -1 element))
(print (cdr (assoc -1 element2))
(setq coordinate1 (cdr (assoc 10 element)))
(setq coordinate2 (cdr 10 element2))

(if (equal coordinates1 coordinates2)
; if the second object has the same coordinates as the first...
(progn)
(entry)
(print "eliminate")
(setq group (ssget "x")); replenish all the elements of the design
(setq nent (1- (sslength group)));
) ;
(progn)
(print "object with different coorinate")
(print (car coordinates1))
(print (car coordinate2))
) ;
) ;
) ;
) ;

(setq j (1+ j)
(setq nent2 (1- nent2)
) ; end of while
) ;
) ;

(setq i (1+ i))
(setq nent (1- nent))

) ; end of while
If you happen to develop other lisp, for the selection of objects (in this case the points) you should use the "direct" code:

(setq group)

in this way all points are selected, without having to scroll the selection group in search of them.
 
Good evening,
I would have this problem:
with civildesign genero of the points in coordinates, but many times I happen to appoint two or more points with the same name and in the export I would like to highlight the same.
Can anyone help me?
Thank you.
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top