lcolville
2005-03-03, 03:29 PM
I wrote this program to try and merge two or more hatch areas into one, taking
into account any internal islands.
I thought this should work but it doesn't. Can anyone tell what I'm doing wrong?
Please help!!!
(defun c:hatch_merge ( / )
(prompt "\nSelect a hatch object to add to...")
(setq ss1 (ssget "_:S" '((-4 . "<OR")(0 . "HATCH")(-4 . "OR>"))))
(setq prime_ent (entget (ssname ss1 0)))
(setq loops (cdr (assoc 91 prime_ent)))
(setq seeds (cdr (assoc 98 prime_ent)))
(setq prime_ent (reverse prime_ent))
(repeat seeds
(setq seed_list (cons (assoc 10 prime_ent) seed_list))
(setq prime_ent (cdr prime_ent))
)
(setq prime_ent (reverse prime_ent))
(prompt "\nSelect the hatch objects to be merged...")
(setq ss2 (ssget '((-4 . "<OR")(0 . "HATCH")(-4 . "OR>"))))
(setq lng (sslength ss2))
(setq n 0)
(repeat lng
(setq add_ent (entget (ssname ss2 n)))
(setq loops (cdr (assoc 91 add_ent)))
(setq seeds (cdr (assoc 98 add_ent)))
(setq add_ent (reverse add_ent))
(repeat seeds
(setq seed_list (cons (assoc 10 add_ent) seed_list))
(setq add_ent (cdr add_ent))
)
(setq add_ent (reverse add_ent))
(setq temp_ent add_ent)
(repeat loops
(setq temp_ent (member (assoc 93 (cdr temp_ent)) temp_ent))
(setq temp (cdr (car temp_ent)))
(setq loop_list (cons temp loop_list))
(setq temp_ent (cdr temp_ent))
(repeat temp
(setq point_list (cons (car temp_ent) point_list))
(setq temp_ent (cdr temp_ent))
)
)
(setq n (+ 1 n))
)
(setq seed_list (reverse seed_list))
(setq loop_list (reverse loop_list))
(setq point_list (reverse point_list))
(setq prime_ent (reverse prime_ent))
(setq build_rep (length loop_list))
(repeat build_rep
(setq prime_ent (cons (cons '93 (car loop_list)) prime_ent))
(repeat (car loop_list)
(setq prime_ent (cons (car point_list) prime_ent))
(setq point_list (cdr point_list))
)
(setq loop_list (cdr loop_list))
)
(setq prime_ent (subst (cons '98 (length seed_list)) (assoc 98 prime_ent) prime_ent))
(setq build_rep (length seed_list))
(repeat build_rep
(setq prime_ent (cons (car seed_list) prime_ent))
(setq seed_list (cdr seed_list))
)
(setq prime_ent (reverse prime_ent))
(setq lng (sslength ss2))
(setq n 0)
(repeat lng
(setq del_ent (entget (ssname ss2 n)))
(entdel del_ent)
(setq n (+ 1 n))
)
(entmod prime_ent)
)
into account any internal islands.
I thought this should work but it doesn't. Can anyone tell what I'm doing wrong?
Please help!!!
(defun c:hatch_merge ( / )
(prompt "\nSelect a hatch object to add to...")
(setq ss1 (ssget "_:S" '((-4 . "<OR")(0 . "HATCH")(-4 . "OR>"))))
(setq prime_ent (entget (ssname ss1 0)))
(setq loops (cdr (assoc 91 prime_ent)))
(setq seeds (cdr (assoc 98 prime_ent)))
(setq prime_ent (reverse prime_ent))
(repeat seeds
(setq seed_list (cons (assoc 10 prime_ent) seed_list))
(setq prime_ent (cdr prime_ent))
)
(setq prime_ent (reverse prime_ent))
(prompt "\nSelect the hatch objects to be merged...")
(setq ss2 (ssget '((-4 . "<OR")(0 . "HATCH")(-4 . "OR>"))))
(setq lng (sslength ss2))
(setq n 0)
(repeat lng
(setq add_ent (entget (ssname ss2 n)))
(setq loops (cdr (assoc 91 add_ent)))
(setq seeds (cdr (assoc 98 add_ent)))
(setq add_ent (reverse add_ent))
(repeat seeds
(setq seed_list (cons (assoc 10 add_ent) seed_list))
(setq add_ent (cdr add_ent))
)
(setq add_ent (reverse add_ent))
(setq temp_ent add_ent)
(repeat loops
(setq temp_ent (member (assoc 93 (cdr temp_ent)) temp_ent))
(setq temp (cdr (car temp_ent)))
(setq loop_list (cons temp loop_list))
(setq temp_ent (cdr temp_ent))
(repeat temp
(setq point_list (cons (car temp_ent) point_list))
(setq temp_ent (cdr temp_ent))
)
)
(setq n (+ 1 n))
)
(setq seed_list (reverse seed_list))
(setq loop_list (reverse loop_list))
(setq point_list (reverse point_list))
(setq prime_ent (reverse prime_ent))
(setq build_rep (length loop_list))
(repeat build_rep
(setq prime_ent (cons (cons '93 (car loop_list)) prime_ent))
(repeat (car loop_list)
(setq prime_ent (cons (car point_list) prime_ent))
(setq point_list (cdr point_list))
)
(setq loop_list (cdr loop_list))
)
(setq prime_ent (subst (cons '98 (length seed_list)) (assoc 98 prime_ent) prime_ent))
(setq build_rep (length seed_list))
(repeat build_rep
(setq prime_ent (cons (car seed_list) prime_ent))
(setq seed_list (cdr seed_list))
)
(setq prime_ent (reverse prime_ent))
(setq lng (sslength ss2))
(setq n 0)
(repeat lng
(setq del_ent (entget (ssname ss2 n)))
(entdel del_ent)
(setq n (+ 1 n))
)
(entmod prime_ent)
)