AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Associate objects from a point to distance test and remove duplicates

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Anonymous
489 Views, 1 Reply

Associate objects from a point to distance test and remove duplicates

Anonymous
Not applicable

(defun sort_inobj ()
(setq x 0 inlis '() elis '())
(repeat (sslength ss)
(setq typ (strcase (cdr (assoc 0 (entget (ssname ss x))))))
(cond
 ((= typ "LINE")(get_llis_ins))
 ((= typ "LWPOLYLINE")(get_llis_ins))
 ((= typ "POINT")(get_plis_ins))
)
(setq x (+ x 1))
)
(princ)
)


(defun get_llis_ins ()
(get_vertex (ssname ss x))
(setq g 0)
(repeat (length ptlis)
(setq pt (nth g ptlis))
(setq inlis (append inlis (list pt)))
(setq elis (append elis (list (ssname ss x))))
(setq g (+ g 1))
)
(princ)
)


(defun get_vertex (ent)
(setq h 0 ena (entget ent) ptlis '())
(repeat (length ena)
(setq itm (car (nth h ena)))
(if (= itm 10)(setq ptlis (append ptlis (list (cdr (nth h ena))))))
(setq h (+ h 1))
)
(princ)
)


(defun get_plis_ins ()
(setq in (cdr (assoc 10 (entget (ssname ss x)))))
(setq inlis (append inlis (list in)))
(setq elis (append elis (list (ssname ss x))))
(princ)
)


(defun associate_objects ()
(setq x 0 alis '())
(repeat (length inlis)
(setq in (nth x inlis))
(setq g 0 lis '())
(repeat (length inlis)
(setq in2 (nth g inlis))
(setq di (distance in in2))
(if (and (< di 10.0)(= (member (nth g elis) lis) nil))(setq lis (append lis (list (nth g elis)))))
(setq g (+ g 1))
)
(setq alis (append alis (list lis)))
(setq x (+ x 1))
)
(princ)
)

 

Association: ((E1, E2,E3)(E2,E4,E5)(E3,E7,E8))

Multiple associations are found for 6 locations, in this particular DWG, with 132 associations. I'm trying to understand how to Dial down this list to another list removing different occurrences. Any help would be appreciated, and thanks in advance!

 

Thanks,

Michael Luckett

 

0 Likes

Associate objects from a point to distance test and remove duplicates

(defun sort_inobj ()
(setq x 0 inlis '() elis '())
(repeat (sslength ss)
(setq typ (strcase (cdr (assoc 0 (entget (ssname ss x))))))
(cond
 ((= typ "LINE")(get_llis_ins))
 ((= typ "LWPOLYLINE")(get_llis_ins))
 ((= typ "POINT")(get_plis_ins))
)
(setq x (+ x 1))
)
(princ)
)


(defun get_llis_ins ()
(get_vertex (ssname ss x))
(setq g 0)
(repeat (length ptlis)
(setq pt (nth g ptlis))
(setq inlis (append inlis (list pt)))
(setq elis (append elis (list (ssname ss x))))
(setq g (+ g 1))
)
(princ)
)


(defun get_vertex (ent)
(setq h 0 ena (entget ent) ptlis '())
(repeat (length ena)
(setq itm (car (nth h ena)))
(if (= itm 10)(setq ptlis (append ptlis (list (cdr (nth h ena))))))
(setq h (+ h 1))
)
(princ)
)


(defun get_plis_ins ()
(setq in (cdr (assoc 10 (entget (ssname ss x)))))
(setq inlis (append inlis (list in)))
(setq elis (append elis (list (ssname ss x))))
(princ)
)


(defun associate_objects ()
(setq x 0 alis '())
(repeat (length inlis)
(setq in (nth x inlis))
(setq g 0 lis '())
(repeat (length inlis)
(setq in2 (nth g inlis))
(setq di (distance in in2))
(if (and (< di 10.0)(= (member (nth g elis) lis) nil))(setq lis (append lis (list (nth g elis)))))
(setq g (+ g 1))
)
(setq alis (append alis (list lis)))
(setq x (+ x 1))
)
(princ)
)

 

Association: ((E1, E2,E3)(E2,E4,E5)(E3,E7,E8))

Multiple associations are found for 6 locations, in this particular DWG, with 132 associations. I'm trying to understand how to Dial down this list to another list removing different occurrences. Any help would be appreciated, and thanks in advance!

 

Thanks,

Michael Luckett

 

1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

Anonymous
Not applicable
Accepted solution

https://forums.autodesk.com/t5/autocad-map-3d-developer/entity-name-to-string-with-conversion-back/t...

 

(defun purge_duplicate_lists ()
(setq x 0 ndlis '())
(repeat (length totlis)
(setq itm (nth x totlis))
(if (= (member itm ndlis) nil)(setq ndlis (append ndlis (list itm))))
(setq x (+ x 1))
)
(princ)
)

 

I did end up separating the points and lines into separate lists, but the code in the citation is enough to get you to this point. I don't deserve any credit for my rating changes based on me answering my own questions, but maybe someone is looking for the same info.

 

Thanks,

Michael Luckett

0 Likes

https://forums.autodesk.com/t5/autocad-map-3d-developer/entity-name-to-string-with-conversion-back/t...

 

(defun purge_duplicate_lists ()
(setq x 0 ndlis '())
(repeat (length totlis)
(setq itm (nth x totlis))
(if (= (member itm ndlis) nil)(setq ndlis (append ndlis (list itm))))
(setq x (+ x 1))
)
(princ)
)

 

I did end up separating the points and lines into separate lists, but the code in the citation is enough to get you to this point. I don't deserve any credit for my rating changes based on me answering my own questions, but maybe someone is looking for the same info.

 

Thanks,

Michael Luckett

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report