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