Author Topic: Associate objects from a point to distance test and remove duplicates  (Read 155 times)

0 Members and 1 Guest are viewing this topic.

M.Luckett

  • Mosquito
  • Posts: 2
Not sure if this is where it belongs, but here goes:

(defun sort_inobj ()
(setq x 0 inlis '() elis '()); The type will be needed later in the code.
(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. This may be rudimentary to some, I get it., But we all have to start somewhere. Thanks in advance.


Thanks,
Michael Luckett