### Author Topic: ==={Challenge}=== Broken Pieces  (Read 8045 times)

0 Members and 1 Guest are viewing this topic.

#### pBe

• Bull Frog
• Posts: 377 ##### Re: ==={Challenge}=== Broken Pieces
« Reply #30 on: June 19, 2013, 01:17:56 AM »

Indeed, it is not a complete solution since I am only comparing the interior angles of pairs of pieces, and not groups of 3, 4, 5,...,n pieces. The ambiguity in the position of the last four pieces arises because I am comparing the outer angles of the edge pieces (i.e. testing for summation to pi radians, rather than 2pi), and several positions will pass this test.

Brilliant approach Lee ... i was "trying" to do the same thing on a counter clockwise direction [angles as basis] using last piece as reference for the next. then worry about the middle pieces later my version:
Code - Auto/Visual Lisp: [Select]
1. (defun c:test (/ A A1 A2 B D L V V1)

Bravo! Very impressive EE.

Matching edges instead of vertices - good method Evgeniy Yes, if all the edges of different lengths

Now i need to re-write the whole thing and use this approach... [try that is]

Code - C#: [Select]
1. [CommandMethod("TOGETHER")]
2. public void cmd_together()....
The above will put together the shapes.-

I'll try this bit later LE.

Thank you all  ##### Re: ==={Challenge}=== Broken Pieces
« Reply #31 on: June 19, 2013, 07:36:27 AM »
Here are my suggestions for optimisations for ElpanovEvgeniy's code:

Code - Auto/Visual Lisp: [Select]
1. (defun c:test ( / a a1 a2 b d e i l s v v1 x y )
2.     (if (setq s (ssget "_:L" '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1))))
3.             (repeat (setq i (sslength s))
4.                 (setq e (ssname s (setq i (1- i)))
5.                       v (mapcar 'cdr (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) (entget e)))
6.                       l (cons (cons (vlax-ename->vla-object e) (mapcar 'list v (cons (last v) v))) l)
7.                 )
8.             )
9.             (setq a (list (car l))
10.                   l (cdr l)
11.             )
12.             (while (and (setq b (car a)) l)
14.                 (foreach c l
15.                     (if (setq d (car (vl-member-if '(lambda ( x ) (equal v (mapcar '- (car x) (cadr x)) 1e-6)) (cdr c))))
16.                             (setq a2 (assoc (car c) l)
18.                                   a1 (cons (cons (car c) (mapcar '(lambda ( x ) (mapcar '(lambda ( y ) (mapcar '- y v1)) x)) (vl-remove d (cdr a2)))) a1)
19.                                    l (vl-remove a2 l)
20.                             )
22.                         )
23.                     )
24.                 )
25.                 (setq a (append (if (cddar a) (cons (cons (car a) (cddar a)) (cdr a)) (cdr a)) a1)
26.                       a1 nil
27.                 )
28.             )
29.         )
30.     )
31.     (princ)
32. )

#### ElpanovEvgeniy ##### Re: ==={Challenge}=== Broken Pieces
« Reply #32 on: June 19, 2013, 07:54:50 AM »
Here are my suggestions for optimisations for ElpanovEvgeniy's code:

Great job!
The code was twice as long Stay home. Stay safe. Save lives.

#### ribarm ##### Re: ==={Challenge}=== Broken Pieces
« Reply #33 on: June 19, 2013, 12:16:10 PM »
Code: [Select]
`(defun c:putmetogether ( / AssocOn LM:ListClockwise-p member-fuzz plvlst llchk prevang nextang suppang anglst dstlst mdpairs reversess llwidchk lllenchk                           p1 p2 vec ss ssss ssss1 ssss2 ssss3 ssss4 ssss5 plnn plx wid len i pl vlst llpls llpl )  (vl-load-com)  (defun AssocOn ( SearchTerm Lst func fuzz )    (car      (vl-member-if        (function          (lambda (pair) (equal SearchTerm (apply func (list pair)) fuzz))        )        lst      )    )  )  (defun LM:ListClockwise-p ( lst )    (minusp       (apply '+         (mapcar          (function            (lambda ( a b )              (- (* (car b) (cadr a)) (* (car a) (cadr b)))            )          ) lst (cons (last lst) lst)        )      )    )  )  (defun member-fuzz ( expr lst fuzz )    (while (and lst (not (equal (car lst) expr fuzz)))      (setq lst (cdr lst))    )    lst  )  (defun plvlst ( pl / vlst pt ptlst )    (setq vlst (vlax-safearray->list (vlax-variant-value (vla-get-coordinates (vlax-ename->vla-object pl)))))    (cond      ( (eq (vla-get-objectname (vlax-ename->vla-object pl)) "AcDbPolyline")        (repeat (/ (length vlst) 2)          (setq pt (list (car vlst) (cadr vlst)))          (setq vlst (cddr vlst))          (setq ptlst (cons pt ptlst))        )        (mapcar '(lambda (x) (trans x 0 1)) (reverse ptlst))      )      ( (eq (vla-get-objectname (vlax-ename->vla-object pl)) "AcDb2dPolyline")        (repeat (/ (length vlst) 3)          (setq pt (list (car vlst) (cadr vlst)))          (setq vlst (cdddr vlst))          (setq ptlst (cons pt ptlst))        )        (mapcar '(lambda (x) (trans x 0 1)) (reverse ptlst))      )    )  )  (defun llchk ( lst / tst )    (mapcar '(lambda (a b c)                (if (and (equal (angle a b) 0.0 1e-6) (equal (angle c a) (* 1.5 pi) 1e-6)) (setq tst (cons T tst)) (setq tst (cons nil tst)))             )              lst              (append (cdr lst) (list (car lst)))              (append (list (last lst)) (reverse (cdr (reverse lst))))    )    (eval (cons 'or tst))  )  (defun prevang ( ang lst / alst )    (setq alst (anglst lst))    (cond      ( (equal ang (car alst) 1e-6)        (last alst)      )      ( (equal ang (last alst) 1e-6)        (cadr (reverse alst))      )      ( (cadr (member-fuzz ang (reverse alst) 1e-6)) )    )  )  (defun nextang ( ang lst / alst )    (setq alst (anglst lst))    (cond      ( (equal ang (car alst) 1e-6)        (cadr alst)      )      ( (equal ang (last alst) 1e-6)        (car alst)      )      ( (cadr (member-fuzz ang alst 1e-6)) )    )  )  (defun suppang ( ang )    (cond      ( (< 0.0 ang pi)        (+ ang pi)      )      ( (< pi ang (* 2.0 pi))        (- ang pi)      )      ( (equal ang pi 1e-6)        0.0      )      ( (or (equal ang 0.0 1e-6) (equal ang (* 2.0 pi) 1e-6))        pi      )    )  )  (defun anglst ( lst / alst )    (setq alst (mapcar '(lambda (a b) (angle a b)) lst (append (cdr lst) (list (car lst)))))  )  (defun dstlst ( lst / dlst )    (setq dlst (mapcar '(lambda (a b) (distance a b)) lst (append (cdr lst) (list (car lst)))))  )  (defun mdpairs ( lst1 lst2 )    (mapcar '(lambda (a b) (cons a b)) lst1 lst2)  )  (defun reversess ( s / sx i ent )    (setq sx (ssadd))    (repeat (setq i (sslength s))      (setq ent (ssname s (setq i (1- i))))      (ssadd ent sx)    )    sx  )  (defun llwidchk ( llpl sss wid / plnchk plnchkk loop i plin pln plnwid )        (defun plnchk ( pln sss wid )      (cond        ( (equal lwid wid 1e-6)          (setq chk T loop nil plx pln)        )        ( (< lwid wid)          (plnchkk pln sss wid)        )        ( (> lwid wid)          (plnchkk pln sss wid)        )      )    )    (defun plnchkk ( pln sss wid / e r )      (if (not sssr)        (progn          (setq sssr (ssadd))          (repeat (setq r (sslength sss))            (setq e (ssname sss (setq r (1- r))))            (ssadd e sssr)          )        )      )      (cond        ( (and pln (not q))          (llwidchk nil (ssdel pln sss) wid)          (if (equal lwid wid 1e-6) (setq chk T loop nil))          (setq q T)        )        ( pln          (llwidchk nil (ssdel pln sssr) wid)          (if (equal lwid wid 1e-6) (setq chk T loop nil))          (setq sssr nil q nil lw nil suppw nil)        )      )    )    (if (not vlstw) (setq vlstw (plvlst llpl)))    (if (not alstw) (setq alstw (anglst vlstw)))    (if (not angn) (setq angn (nextang 0.0 vlstw)))    (if (not suppangn) (setq suppangn (suppang angn)))    (if (not llplwid) (setq llplwid (cdr (assocon 0.0 (mdpairs alstw (dstlst vlstw)) 'car 1e-6))))    (if (not lwid) (setq lwid llplwid))    (if (not dstchk1) (setq dstchk1 (cdr (assocon angn (mdpairs alstw (dstlst vlstw)) 'car 1e-6))))    (setq i -1)    (setq loop T)    (if (equal lwid wid 1e-6) (setq chk T loop nil))    (while (and (setq plin (if sss (ssname sss (setq i (1+ i))) nil)) loop)      (if (not lw) (setq lw lwid))      (if (not suppw) (setq suppw suppangn))      (if q (setq suppangn suppw lwid lw))      (if (member-fuzz suppangn (anglst (plvlst plin)) 1e-6)        (setq pln plin)        (setq pln nil)      )      (if pln        (progn          (setq plnwid (cdr (assocon 0.0 (mdpairs (anglst (plvlst pln)) (dstlst (plvlst pln))) 'car 1e-6))                dstchk2 (cdr (assocon suppangn (mdpairs (anglst (plvlst pln)) (dstlst (plvlst pln))) 'car 1e-6))          )          (setq vlstw (plvlst pln) alstw (anglst vlstw) angn (if (not (equal (nextang suppangn vlstw) 0.0 1e-6)) (nextang suppangn vlstw) (nextang 0.0 vlstw)))          (if (equal dstchk1 dstchk2 1e-6)             (setq suppangn (suppang angn) dstchk1 (cdr (assocon angn (mdpairs (anglst (plvlst pln)) (dstlst (plvlst pln))) 'car 1e-6)))            (setq plnwid nil)          )        )      )      (if plnwid        (progn          (setq lwid (+ lwid plnwid))          (plnchk pln sss wid)        )        (if pln (plnchk pln sss wid))      )    )    (list chk plx)  )  (defun lllenchk ( llpl sss len / plpchk plpchkk loop i plin plp plplen )    (defun plpchk ( plp sss len )      (cond        ( (equal llen len 1e-6)          (setq chk T loop nil)        )        ( (< llen len)          (plpchkk plp sss len)        )        ( (> llen len)          (plpchkk plp sss len)        )      )      )    (defun plpchkk ( plp sss len / e r )      (if (not sssr)        (progn          (setq sssr (ssadd))          (repeat (setq r (sslength sss))            (setq e (ssname sss (setq r (1- r))))            (ssadd e sssr)          )        )      )      (cond        ( (and (not q) plp)          (lllenchk nil (ssdel plp sss) len)          (if (equal llen len 1e-6) (setq chk T loop nil))          (setq q T)        )        ( plp          (lllenchk nil (ssdel plp sssr) len)          (if (equal llen len 1e-6) (setq chk T loop nil))          (setq sssr nil q nil ll nil suppl nil)        )      )    )        (if (not vlstl) (setq vlstl (plvlst llpl)))    (if (not alstl) (setq alstl (anglst vlstl)))    (if (not angp) (setq angp (prevang (* 1.5 pi) vlstl)))    (if (not suppangp) (setq suppangp (suppang angp)))    (if (not llpllen) (setq llpllen (cdr (assocon (* 1.5 pi) (mdpairs alstl (dstlst vlstl)) 'car 1e-6))))    (if (not llen) (setq llen llpllen))    (if (not dstchk1) (setq dstchk1 (cdr (assocon angp (mdpairs alstl (dstlst vlstl)) 'car 1e-6))))    (setq i -1)    (setq loop T)    (if (equal llen len 1e-6) (setq chk T loop nil))    (while (and (setq plin (if sss (ssname sss (setq i (1+ i))) nil)) loop)      (if (not ll) (setq ll llen))      (if (not suppl) (setq suppl suppangp))      (if q (setq suppangp suppl llen ll))      (if (member-fuzz suppangp (anglst (plvlst plin)) 1e-6)        (setq plp plin)        (setq plp nil)      )      (if plp        (progn          (setq plplen (cdr (assocon (* 1.5 pi) (mdpairs (anglst (plvlst plp)) (dstlst (plvlst plp))) 'car 1e-6))                dstchk2 (cdr (assocon suppangp (mdpairs (anglst (plvlst plp)) (dstlst (plvlst plp))) 'car 1e-6))          )          (setq vlstl (plvlst plp) alstl (anglst vlstl) angp (if (not (equal (prevang suppangp vlstl) (* 1.5 pi) 1e-6)) (prevang suppangp vlstl) (prevang (* 1.5 pi) vlstl)))          (if (equal dstchk1 dstchk2 1e-6)             (setq suppangp (suppang angp) dstchk1 (cdr (assocon angp (mdpairs (anglst (plvlst plp)) (dstlst (plvlst plp))) 'car 1e-6)))            (setq plplen nil)          )        )      )      (if plplen        (progn          (setq llen (+ llen plplen))          (plpchk plp sss len)        )        (if plp (plpchk plp sss len))      )    )    chk  )  (command "_.ucs" "w")  (setq ss (ssget "_:L" '((0 . "*POLYLINE") (-4 . "&=") (70 . 1))))  (setq p1 (getpoint "\nPick start corner : "))  (setq p2 (getcorner p1 "\nPick end corner : "))  (setq vec (mapcar '- p2 p1))  (setq wid (abs (car vec)))  (setq len (abs (cadr vec)))    (setq ssss (ssadd))  (setq ssss1 (ssadd) ssss2 (ssadd) ssss3 (ssadd) ssss4 (ssadd) ssss5 (ssadd))  (setq i -1)  (command "_.ucs" "w")  (while (setq pl (ssname ss (setq i (1+ i))))    (setq vlst (plvlst pl))    (if (LM:ListClockwise-p vlst)       (progn         (command "_.reverse" pl "")         (setq vlst (plvlst pl))      )    )    (if (llchk vlst) (setq llpls (cons pl llpls)))    (ssadd pl ssss1)    (ssadd pl ssss2)    (ssadd pl ssss3)    (ssadd pl ssss4)    (ssadd pl ssss5)  )  (foreach plll (reverse llpls)    (ssdel plll ssss1)    (ssdel plll ssss2)    (ssdel plll ssss3)    (ssdel plll ssss4)    (setq vlstw nil alstw nil angn nil suppangn nil suppw nil lw nil llplwid nil lwid nil dstchk1 nil dstchk2 nil chk nil q nil)    (setq wchk1 (if (eq (car (setq plnn (llwidchk plll ssss1 wid))) T) (progn (setq plnn (cadr plnn)) T) nil))    (setq vlstw nil alstw nil angn nil suppangn nil suppw nil lw nil llplwid nil lwid nil dstchk1 nil dstchk2 nil chk nil q nil)    (setq wchk2 (if (eq (car (setq plnn (llwidchk plll (setq sss (reversess ssss2)) wid))) T) (progn (setq plnn (cadr plnn)) T) nil))    (setq vlstl nil alstl nil angp nil suppangp nil suppl nil ll nil llpllen nil llen nil dstchk1 nil dstchk2 nil chk nil q nil)    (setq lchk1 (lllenchk plll ssss3 len))    (setq vlstl nil alstl nil angp nil suppangp nil suppl nil ll nil llpllen nil llen nil dstchk1 nil dstchk2 nil chk nil q nil)    (setq lchk2 (lllenchk plll (setq sss (reversess ssss4)) len))    (if (and           (or wchk1 wchk2)           (or lchk1 lchk2)        )        (setq llpl plll)    )    (setq wchk1 nil wchk2 nil lchk1 nil lchk2 nil)    (setq ssss1 (ssadd) ssss2 (ssadd) ssss3 (ssadd) ssss4 (ssadd))    (setq i -1)    (while (setq pl (ssname ssss5 (setq i (1+ i))))      (ssadd pl ssss1)      (ssadd pl ssss2)      (ssadd pl ssss3)      (ssadd pl ssss4)    )  )  (ssdel plnn ssss1)  (ssdel plnn ssss2)  (ssdel plnn ssss3)  (ssdel plnn ssss4)  (ssadd plnn ssss1)  (ssadd plnn ssss2)  (ssadd plnn ssss3)  (ssadd plnn ssss4)  (prompt "\nLower-left 2d polyline is highlighted - ENTER TO CONTINUE")  (ssadd llpl ssss)  (sssetfirst nil (ssadd llpl))  (setq llpls nil)  (command "\\")  (setq i -1)  (command "_.ucs" "z" 90)  (while (setq pl (ssname ssss1 (setq i (1+ i))))    (setq vlst (plvlst pl))    (if (LM:ListClockwise-p vlst)       (progn         (command "_.reverse" pl "")         (setq vlst (plvlst pl))      )    )    (if (llchk vlst) (setq llpls (cons pl llpls)))  )  (foreach plll (reverse llpls)    (ssdel plll ssss1)    (ssdel plll ssss2)    (ssdel plll ssss3)    (ssdel plll ssss4)    (setq vlstw nil alstw nil angn nil suppangn nil suppw nil lw nil llplwid nil lwid nil dstchk1 nil dstchk2 nil chk nil q nil)    (setq wchk1 (if (eq (car (setq plnn (llwidchk plll ssss1 len))) T) (progn (setq plnn (cadr plnn)) T) nil))    (setq vlstw nil alstw nil angn nil suppangn nil suppw nil lw nil llplwid nil lwid nil dstchk1 nil dstchk2 nil chk nil q nil)    (setq wchk2 (if (eq (car (setq plnn (llwidchk plll (setq sss (reversess ssss2)) len))) T) (progn (setq plnn (cadr plnn)) T) nil))    (setq vlstl nil alstl nil angp nil suppangp nil suppl nil ll nil llpllen nil llen nil dstchk1 nil dstchk2 nil chk nil q nil)    (setq lchk1 (lllenchk plll ssss3 wid))    (setq vlstl nil alstl nil angp nil suppangp nil suppl nil ll nil llpllen nil llen nil dstchk1 nil dstchk2 nil chk nil q nil)    (setq lchk2 (lllenchk plll (setq sss (reversess ssss4)) wid))    (if (and           (or wchk1 wchk2)           (or lchk1 lchk2)        )        (setq llpl plll)    )    (setq wchk1 nil wchk2 nil lchk1 nil lchk2 nil)    (setq ssss1 (ssadd) ssss2 (ssadd) ssss3 (ssadd) ssss4 (ssadd))    (setq i -1)    (while (setq pl (ssname ssss5 (setq i (1+ i))))      (ssadd pl ssss1)      (ssadd pl ssss2)      (ssadd pl ssss3)      (ssadd pl ssss4)    )  )  (ssdel plnn ssss1)  (ssdel plnn ssss2)  (ssdel plnn ssss3)  (ssdel plnn ssss4)  (ssadd plnn ssss1)  (ssadd plnn ssss2)  (ssadd plnn ssss3)  (ssadd plnn ssss4)  (prompt "\nLower-right 2d polyline is highlighted - ENTER TO CONTINUE")  (ssadd llpl ssss)  (sssetfirst nil (ssadd llpl))  (setq llpls nil)  (command "\\")  (setq i -1)  (command "_.ucs" "z" 90)  (while (setq pl (ssname ssss1 (setq i (1+ i))))    (setq vlst (plvlst pl))    (if (LM:ListClockwise-p vlst)       (progn         (command "_.reverse" pl "")         (setq vlst (plvlst pl))      )    )    (if (llchk vlst) (setq llpls (cons pl llpls)))  )  (foreach plll (reverse llpls)    (ssdel plll ssss1)    (ssdel plll ssss2)    (ssdel plll ssss3)    (ssdel plll ssss4)    (setq vlstw nil alstw nil angn nil suppangn nil suppw nil lw nil llplwid nil lwid nil dstchk1 nil dstchk2 nil chk nil q nil)    (setq wchk1 (if (eq (car (setq plnn (llwidchk plll ssss1 wid))) T) (progn (setq plnn (cadr plnn)) T) nil))    (setq vlstw nil alstw nil angn nil suppangn nil suppw nil lw nil llplwid nil lwid nil dstchk1 nil dstchk2 nil chk nil q nil)    (setq wchk2 (if (eq (car (setq plnn (llwidchk plll (setq sss (reversess ssss2)) wid))) T) (progn (setq plnn (cadr plnn)) T) nil))    (setq vlstl nil alstl nil angp nil suppangp nil suppl nil ll nil llpllen nil llen nil dstchk1 nil dstchk2 nil chk nil q nil)    (setq lchk1 (lllenchk plll ssss3 len))    (setq vlstl nil alstl nil angp nil suppangp nil suppl nil ll nil llpllen nil llen nil dstchk1 nil dstchk2 nil chk nil q nil)    (setq lchk2 (lllenchk plll (setq sss (reversess ssss4)) len))    (if (and           (or wchk1 wchk2)           (or lchk1 lchk2)        )        (setq llpl plll)    )    (setq wchk1 nil wchk2 nil lchk1 nil lchk2 nil)    (setq ssss1 (ssadd) ssss2 (ssadd) ssss3 (ssadd) ssss4 (ssadd))    (setq i -1)    (while (setq pl (ssname ssss5 (setq i (1+ i))))      (ssadd pl ssss1)      (ssadd pl ssss2)      (ssadd pl ssss3)      (ssadd pl ssss4)    )  )  (ssdel plnn ssss1)  (ssdel plnn ssss2)  (ssdel plnn ssss3)  (ssdel plnn ssss4)  (ssadd plnn ssss1)  (ssadd plnn ssss2)  (ssadd plnn ssss3)  (ssadd plnn ssss4)  (prompt "\nUpper-right 2d polyline is highlighted - ENTER TO CONTINUE")  (ssadd llpl ssss)  (sssetfirst nil (ssadd llpl))  (setq llpls nil)  (command "\\")  (setq i -1)  (command "_.ucs" "z" 90)  (while (setq pl (ssname ssss1 (setq i (1+ i))))    (setq vlst (plvlst pl))    (if (LM:ListClockwise-p vlst)       (progn         (command "_.reverse" pl "")         (setq vlst (plvlst pl))      )    )    (if (llchk vlst) (setq llpls (cons pl llpls)))  )  (foreach plll (reverse llpls)    (ssdel plll ssss1)    (ssdel plll ssss2)    (ssdel plll ssss3)    (ssdel plll ssss4)    (setq vlstw nil alstw nil angn nil suppangn nil suppw nil lw nil llplwid nil lwid nil dstchk1 nil dstchk2 nil chk nil q nil)    (setq wchk1 (if (eq (car (setq plnn (llwidchk plll ssss1 len))) T) (progn (setq plnn (cadr plnn)) T) nil))    (setq vlstw nil alstw nil angn nil suppangn nil suppw nil lw nil llplwid nil lwid nil dstchk1 nil dstchk2 nil chk nil q nil)    (setq wchk2 (if (eq (car (setq plnn (llwidchk plll (setq sss (reversess ssss2)) len))) T) (progn (setq plnn (cadr plnn)) T) nil))    (setq vlstl nil alstl nil angp nil suppangp nil suppl nil ll nil llpllen nil llen nil dstchk1 nil dstchk2 nil chk nil q nil)    (setq lchk1 (lllenchk plll ssss3 wid))    (setq vlstl nil alstl nil angp nil suppangp nil suppl nil ll nil llpllen nil llen nil dstchk1 nil dstchk2 nil chk nil q nil)    (setq lchk2 (lllenchk plll (setq sss (reversess ssss4)) wid))    (if (and           (or wchk1 wchk2)           (or lchk1 lchk2)        )        (setq llpl plll)    )    (setq wchk1 nil wchk2 nil lchk1 nil lchk2 nil)    (setq ssss1 (ssadd) ssss2 (ssadd) ssss3 (ssadd) ssss4 (ssadd))    (setq i -1)    (while (setq pl (ssname ssss5 (setq i (1+ i))))      (ssadd pl ssss1)      (ssadd pl ssss2)      (ssadd pl ssss3)      (ssadd pl ssss4)    )  )  (ssdel plnn ssss1)  (ssdel plnn ssss2)  (ssdel plnn ssss3)  (ssdel plnn ssss4)  (ssadd plnn ssss1)  (ssadd plnn ssss2)  (ssadd plnn ssss3)  (ssadd plnn ssss4)  (setq vlstw nil alstw nil angn nil suppangn nil suppw nil lw nil llplwid nil lwid nil dstchk1 nil dstchk2 nil chk nil q nil)  (setq vlstl nil alstl nil angp nil suppangp nil suppl nil ll nil llpllen nil llen nil dstchk1 nil dstchk2 nil chk nil q nil)  (prompt "\nUpper-left 2d polyline is highlighted - ENTER TO CONTINUE")  (ssadd llpl ssss)  (sssetfirst nil (ssadd llpl))  (setq llpls nil)  (command "\\")  (command "_.ucs" "w")  (prompt "\nAll corner 2d polylines are highlighted")  (sssetfirst nil ssss)    (princ))`
EDIT : Shortened version...
« Last Edit: June 20, 2013, 12:30:49 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture) #### ribarm ##### Re: ==={Challenge}=== Broken Pieces
« Reply #34 on: June 20, 2013, 06:30:37 AM »
Can someone see what's wrong with my above posted code - it has changed - now is bigger - I hardly put it in code tags around 20000 chr...

As I explained before, I was trying to solve tiles situation - see my posted before *-MR3.dwg... The main problem is that checks for entity when UCS is already rotated 180 degree returns nil... As I explained, lower-left pline is checked this way :
- width checking - checking for next angle and edge distance - two situations :
- if next angle of next entity is 0.0 degree than this is correct entity and it's width is added consequently to be checked with total width
- if next angle of next entity isn't 0.0 degree then this next angle is stored for next check entity - all until one next angle is 0.0 degree, that entity width is added consequently to be checked with total width
- if summed width is equal to total width then last entity is stored into list from witch is later obtained for putting it as last entity in modified selection sets for next iteration (rotation of UCS)... This entity is then last candidate in next checking and therefore should be highlighted as next corner pline...
* if width check isn't correct than this candidate entity fails (note that in my case - tiles - each candidate should pass test for both width and length)

- length checking - checking for previous angle and edge distance - two situations :
- if previous angle of previous entity is (* 1.5 pi) degree than this is correct entity and it's width is added consequently to be checked with total length
- if previous angle of previous entity isn't (* 1.5 pi) degree then this previous angle is stored for next check entity - all until one previous angle is (* 1.5 pi) degree, that entity length is added consequently to be checked with total length

Please if you have some time see what you can do with this code... Now is failing after two UCS rotations by 90 degrees...

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)  ##### Re: ==={Challenge}=== Broken Pieces
« Reply #35 on: June 20, 2013, 06:39:40 AM »
Here are my suggestions for optimisations for ElpanovEvgeniy's code:

Great job!
The code was twice as long Thank you! #### ribarm ##### Re: ==={Challenge}=== Broken Pieces
« Reply #36 on: June 20, 2013, 12:32:54 PM »
I have shortened my code, but still the same problems...

No one to help - even look... Regards, M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture) #### ribarm ##### Re: ==={Challenge}=== Broken Pieces
« Reply #37 on: June 21, 2013, 06:55:44 PM »
New solution... Works for tiles, but still can't be fully reliable... I don't know why...

Code - Auto/Visual Lisp: [Select]
1. (defun c:putmetogether ( / AssocOn LM:ListClockwise-p member-fuzz plvlst llchk prevang nextang suppang anglst dstlst mdpairs reversess dstangchk llwidchk lllenchk
2.                            p1 p2 vec ss ssss ssss1 ssss2 ssss3 ssss4 wid len i pl vlst llpls llpl plnn plmm )
3.
4.
5.   (defun AssocOn ( SearchTerm Lst func fuzz )
6.     (car
7.       (vl-member-if
8.           (lambda (pair) (equal SearchTerm (apply func (list pair)) fuzz))
9.         )
10.         lst
11.       )
12.     )
13.   )
14.
15.   (defun LM:ListClockwise-p ( lst )
16.       (apply '+
17.             (lambda ( a b )
18.               (- (* (car b) (cadr a)) (* (car a) (cadr b)))
19.             )
20.           ) lst (cons (last lst) lst)
21.         )
22.       )
23.     )
24.   )
25.
26.   (defun member-fuzz ( expr lst fuzz )
27.     (while (and lst (not (equal (car lst) expr fuzz)))
28.       (setq lst (cdr lst))
29.     )
30.     lst
31.   )
32.
33.   (defun plvlst ( pl / vlst pt ptlst )
34.     (setq vlst (vlax-safearray->list (vlax-variant-value (vla-get-coordinates (vlax-ename->vla-object pl)))))
35.     (cond
36.       ( (eq (vla-get-objectname (vlax-ename->vla-object pl)) "AcDbPolyline")
37.         (repeat (/ (length vlst) 2)
38.           (setq pt (list (car vlst) (cadr vlst)))
39.           (setq vlst (cddr vlst))
40.           (setq ptlst (cons pt ptlst))
41.         )
42.         (mapcar '(lambda (x) (trans x 0 1)) (reverse ptlst))
43.       )
44.       ( (eq (vla-get-objectname (vlax-ename->vla-object pl)) "AcDb2dPolyline")
45.         (repeat (/ (length vlst) 3)
46.           (setq pt (list (car vlst) (cadr vlst)))
47.           (setq vlst (cdddr vlst))
48.           (setq ptlst (cons pt ptlst))
49.         )
50.         (mapcar '(lambda (x) (trans x 0 1)) (reverse ptlst))
51.       )
52.     )
53.   )
54.
55.   (defun llchk ( lst / tst )
56.     (mapcar '(lambda (a b c)
57.                (if (and (equal (angle a b) 0.0 1e-6) (equal (angle c a) (* 1.5 pi) 1e-6)) (setq tst (cons T tst)) (setq tst (cons nil tst)))
58.              )
59.              lst
60.              (append (cdr lst) (list (car lst)))
61.              (append (list (last lst)) (reverse (cdr (reverse lst))))
62.     )
63.     (eval (cons 'or tst))
64.   )
65.
66.   (defun prevang ( ang lst / alst )
67.     (setq alst (anglst lst))
68.     (cond
69.       ( (equal ang (car alst) 1e-6)
70.         (last alst)
71.       )
72.       ( (equal ang (last alst) 1e-6)
74.       )
75.       ( (cadr (member-fuzz ang (reverse alst) 1e-6)) )
76.     )
77.   )
78.
79.   (defun nextang ( ang lst / alst )
80.     (setq alst (anglst lst))
81.     (cond
82.       ( (equal ang (car alst) 1e-6)
84.       )
85.       ( (equal ang (last alst) 1e-6)
86.         (car alst)
87.       )
88.       ( (cadr (member-fuzz ang alst 1e-6)) )
89.     )
90.   )
91.
92.   (defun suppang ( ang )
93.     (cond
94.       ( (< 0.0 ang pi)
95.         (+ ang pi)
96.       )
97.       ( (< pi ang (* 2.0 pi))
98.         (- ang pi)
99.       )
100.       ( (equal ang pi 1e-6)
101.         0.0
102.       )
103.       ( (or (equal ang 0.0 1e-6) (equal ang (* 2.0 pi) 1e-6))
104.         pi
105.       )
106.     )
107.   )
108.
109.   (defun anglst ( lst / alst )
110.     (setq alst (mapcar '(lambda (a b) (angle a b)) lst (append (cdr lst) (list (car lst)))))
111.   )
112.
113.   (defun dstlst ( lst / dlst )
114.     (setq dlst (mapcar '(lambda (a b) (distance a b)) lst (append (cdr lst) (list (car lst)))))
115.   )
116.
117.   (defun mdpairs ( lst1 lst2 )
118.     (mapcar '(lambda (a b) (cons a b)) lst1 lst2)
119.   )
120.
121.   (defun reversess ( s / sx i ent )
123.     (repeat (setq i (sslength s))
124.       (setq ent (ssname s (setq i (1- i))))
126.     )
127.     sx
128.   )
129.
130.   (defun dstangchk ( d a ss / i e pairs elst )
131.     (setq i -1)
132.     (while (setq e (ssname ss (setq i (1+ i))))
133.       (setq pairs (mdpairs (anglst (plvlst e)) (dstlst (plvlst e))))
134.       (if (equal d (cdr (assocon a pairs 'car 1e-6)) 1e-6)
135.         (setq elst (cons e elst))
136.       )
137.     )
138.     elst
139.   )
140.
141.   (defun llwidchk ( llpl sss wid / flag an sn dn )
142.     (setq vlstw (plvlst llpl))
143.     (setq alstw (anglst vlstw))
144.     (if (not angn) (setq angn (nextang 0.0 vlstw)))
145.     (if (not suppangn) (setq suppangn (suppang angn)))
146.     (if (not llplwid) (setq llplwid (cdr (assocon 0.0 (mdpairs alstw (dstlst vlstw)) 'car 1e-6))))
147.     (if (not lwid) (setq lwid llplwid))
148.     (if (not dstnn) (setq dstnn (cdr (assocon angn (mdpairs alstw (dstlst vlstw)) 'car 1e-6))))
149.     (setq plns (dstangchk dstnn suppangn sss))
150.     (if plns
151.         (foreach pln plns
152.           (setq plnwid (cdr (assocon 0.0 (mdpairs (anglst (plvlst pln)) (dstlst (plvlst pln))) 'car 1e-6)))
153.           (setq dstnn (cdr (assocon (nextang 0.0 (plvlst pln)) (mdpairs (anglst (plvlst pln)) (dstlst (plvlst pln))) 'car 1e-6)))
154.           (if (nextang 0.0 (plvlst pln)) (setq angn (nextang 0.0 (plvlst pln))))
155.           (if angn (setq suppangn (suppang angn)))
156.           (if (and plnwid dstnn (not flag))
157.             (setq lwid (+ lwid plnwid) npl pln an angn sn suppangn dn dstnn flag T)
158.           )
159.         )
160.         (if (and an sn dn) (setq angn an suppangn sn dstnn dn))
161.         (if (equal lwid wid 1e-6) (setq chk T plx npl)
162.           (if (< lwid wid)
163.               (if (not flag) (setq npl (car plns)))
164.               (if (and npl flag)
165.                 (llwidchk npl (ssdel npl sss) wid)
166.                   (setq suppangn (suppang (setq angn (nextang suppangn (plvlst npl)))))
167.                   (setq dstnn (cdr (assocon angn (mdpairs (anglst (plvlst npl)) (dstlst (plvlst npl))) 'car 1e-6)))
168.                   (llwidchk npl (ssdel npl sss) wid)
169.                 )
170.               )
171.             )
172.           )
173.         )
174.       )
175.     )
176.     (list chk plx)
177.   )
178.
179.   (defun lllenchk ( llpl sss len / flag ap sp dp )
180.     (setq vlstl (plvlst llpl))
181.     (setq alstl (anglst vlstl))
182.     (if (not angp) (setq angp (prevang (* 1.5 pi) vlstl)))
183.     (if (not suppangp) (setq suppangp (suppang angp)))
184.     (if (not llpllen) (setq llpllen (cdr (assocon (* 1.5 pi) (mdpairs alstl (dstlst vlstl)) 'car 1e-6))))
185.     (if (not llen) (setq llen llpllen))
186.     (if (not dstpp) (setq dstpp (cdr (assocon angp (mdpairs alstl (dstlst vlstl)) 'car 1e-6))))
187.     (setq plps (dstangchk dstpp suppangp sss))
188.     (if plps
189.         (foreach plp plps
190.           (setq plplen (cdr (assocon (* 1.5 pi) (mdpairs (anglst (plvlst plp)) (dstlst (plvlst plp))) 'car 1e-6)))
191.           (setq dstpp (cdr (assocon (prevang (* 1.5 pi) (plvlst plp)) (mdpairs (anglst (plvlst plp)) (dstlst (plvlst plp))) 'car 1e-6)))
192.           (if (prevang (* 1.5 pi) (plvlst plp)) (setq angp (prevang (* 1.5 pi) (plvlst plp))))
193.           (if angp (setq suppangp (suppang angp)))
194.           (if (and plplen dstpp (not flag))
195.             (setq llen (+ llen plplen) ppl plp ap angp sp suppangp dp dstpp flag T)
196.           )
197.         )
198.         (if (and ap sp dp) (setq angp ap suppangp sp dstpp dp))
199.         (if (equal llen len 1e-6) (setq chk T ply ppl)
200.           (if (< llen len)
201.               (if (not flag) (setq ppl (car plps)))
202.               (if (and ppl flag)
203.                 (lllenchk ppl (ssdel ppl sss) len)
204.                   (setq suppangp (suppang (setq angp (prevang suppangp (plvlst ppl)))))
205.                   (setq dstpp (cdr (assocon angp (mdpairs (anglst (plvlst ppl)) (dstlst (plvlst ppl))) 'car 1e-6)))
206.                   (lllenchk ppl (ssdel ppl sss) len)
207.                 )
208.               )
209.             )
210.           )
211.         )
212.       )
213.     )
214.     (list chk ply)
215.   )
216.
217.   (command "_.ucs" "w")
218.   (setq ss (ssget "_:L" '((0 . "*POLYLINE") (-4 . "&=") (70 . 1))))
219.   (setq p1 (getpoint "\nPick start corner : "))
220.   (setq p2 (getcorner p1 "\nPick end corner : "))
221.   (setq vec (mapcar '- p2 p1))
222.   (setq wid (abs (car vec)))
223.   (setq len (abs (cadr vec)))
224.
227.   (setq i -1)
228.   (command "_.ucs" "w")
229.   (while (setq pl (ssname ss (setq i (1+ i))))
230.     (setq vlst (plvlst pl))
231.     (if (LM:ListClockwise-p vlst)
232.         (command "_.reverse" pl "")
233.         (setq vlst (plvlst pl))
234.       )
235.     )
236.     (if (llchk vlst) (setq llpls (cons pl llpls)))
241.   )
242.   (foreach plll (reverse llpls)
243.     (ssdel plll ssss1)
244.     (ssdel plll ssss2)
245.     (ssdel plll ssss3)
246.     (ssdel plll ssss4)
247.     (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
248.     (setq wchk1 (if (eq (car (setq plnn (llwidchk plll ssss1 wid))) T) (progn (setq plnn (cadr plnn)) T) nil))
249.     (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
250.     (setq wchk2 (if (eq (car (setq plnn (llwidchk plll (setq sss (reversess ssss2)) wid))) T) (progn (setq plnn (cadr plnn)) T) nil))
251.     (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
252.     (setq lchk1 (if (eq (car (setq plmm (lllenchk plll ssss3 len))) T) (progn (setq plmm (cadr plmm)) T) nil))
253.     (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
254.     (setq lchk2 (if (eq (car (setq plmm (lllenchk plll (setq sss (reversess ssss4)) len))) T) (progn (setq plmm (cadr plmm)) T) nil))
255.     (if (and
256.           (or wchk1 wchk2)
257.           (or lchk1 lchk2)
258.         )
259.         (setq llpl plll)
260.     )
261.     (setq wchk1 nil wchk2 nil lchk1 nil lchk2 nil)
263.     (setq i -1)
264.     (while (setq pl (ssname ss (setq i (1+ i))))
269.     )
270.   )
271.   (if plnn (ssdel plnn ssss1))
272.   (if plnn (ssdel plnn ssss2))
273.   (if plnn (ssdel plnn ssss3))
274.   (if plnn (ssdel plnn ssss4))
275.   (if plnn (ssadd plnn ssss1))
276.   (if plnn (ssadd plnn ssss2))
277.   (if plnn (ssadd plnn ssss3))
278.   (if plnn (ssadd plnn ssss4))
279.   (prompt "\nLower-left 2d polyline is highlighted - ENTER TO CONTINUE")
282.   (setq llpls nil)
283.   (command "\\")
284.
285.   (setq i -1)
286.   (command "_.ucs" "z" 90)
287.   (while (setq pl (ssname ssss1 (setq i (1+ i))))
288.     (setq vlst (plvlst pl))
289.     (if (LM:ListClockwise-p vlst)
290.         (command "_.reverse" pl "")
291.         (setq vlst (plvlst pl))
292.       )
293.     )
294.     (if (llchk vlst) (setq llpls (cons pl llpls)))
295.   )
296.   (foreach plll (reverse llpls)
297.     (ssdel plll ssss1)
298.     (ssdel plll ssss2)
299.     (ssdel plll ssss3)
300.     (ssdel plll ssss4)
301.     (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
302.     (setq wchk1 (if (eq (car (setq plnn (llwidchk plll ssss1 len))) T) (progn (setq plnn (cadr plnn)) T) nil))
303.     (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
304.     (setq wchk2 (if (eq (car (setq plnn (llwidchk plll (setq sss (reversess ssss2)) len))) T) (progn (setq plnn (cadr plnn)) T) nil))
305.     (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
306.     (setq lchk1 (if (eq (car (lllenchk plll ssss3 wid)) T) T nil))
307.     (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
308.     (setq lchk2 (if (eq (car (lllenchk plll (setq sss (reversess ssss4)) wid)) T) T nil))
309.     (if (and
310.           (or wchk1 wchk2)
311.           (or lchk1 lchk2)
312.         )
313.         (setq llpl plll)
314.     )
315.     (setq wchk1 nil wchk2 nil lchk1 nil lchk2 nil)
317.     (setq i -1)
318.     (while (setq pl (ssname ss (setq i (1+ i))))
323.     )
324.   )
325.   (if plnn (ssdel plnn ssss1))
326.   (if plnn (ssdel plnn ssss2))
327.   (if plnn (ssdel plnn ssss3))
328.   (if plnn (ssdel plnn ssss4))
329.   (if plnn (ssadd plnn ssss1))
330.   (if plnn (ssadd plnn ssss2))
331.   (if plnn (ssadd plnn ssss3))
332.   (if plnn (ssadd plnn ssss4))
333.   (prompt "\nLower-right 2d polyline is highlighted - ENTER TO CONTINUE")
336.   (setq llpls nil)
337.   (command "\\")
338.
339.   (setq i -1)
340.   (command "_.ucs" "z" 90)
341.   (while (setq pl (ssname ssss1 (setq i (1+ i))))
342.     (setq vlst (plvlst pl))
343.     (if (LM:ListClockwise-p vlst)
344.         (command "_.reverse" pl "")
345.         (setq vlst (plvlst pl))
346.       )
347.     )
348.     (if (llchk vlst) (setq llpls (cons pl llpls)))
349.   )
350.   (foreach plll (reverse llpls)
351.     (ssdel plll ssss1)
352.     (ssdel plll ssss2)
353.     (ssdel plll ssss3)
354.     (ssdel plll ssss4)
355.     (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
356.     (setq wchk1 (if (eq (car (setq plnn (llwidchk plll ssss1 wid))) T) (progn (setq plnn (cadr plnn)) T) nil))
357.     (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
358.     (setq wchk2 (if (eq (car (setq plnn (llwidchk plll (setq sss (reversess ssss2)) wid))) T) (progn (setq plnn (cadr plnn)) T) nil))
359.     (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
360.     (setq lchk1 (if (eq (car (lllenchk plll ssss3 len)) T) T nil))
361.     (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
362.     (setq lchk2 (if (eq (car (lllenchk plll (setq sss (reversess ssss4)) len)) T) T nil))
363.     (if (and
364.           (or wchk1 wchk2)
365.           (or lchk1 lchk2)
366.         )
367.         (setq llpl plll)
368.     )
369.     (setq wchk1 nil wchk2 nil lchk1 nil lchk2 nil)
371.     (setq i -1)
372.     (while (setq pl (ssname ss (setq i (1+ i))))
377.     )
378.   )
379.   (if plnn (ssdel plnn ssss1))
380.   (if plnn (ssdel plnn ssss2))
381.   (if plnn (ssdel plnn ssss3))
382.   (if plnn (ssdel plnn ssss4))
383.   (if plnn (ssadd plnn ssss1))
384.   (if plnn (ssadd plnn ssss2))
385.   (if plnn (ssadd plnn ssss3))
386.   (if plnn (ssadd plnn ssss4))
387.   (if plmm (ssdel plmm ssss1))
388.   (if plmm (ssdel plmm ssss2))
389.   (if plmm (ssdel plmm ssss3))
390.   (if plmm (ssdel plmm ssss4))
391.   (if plmm (ssadd plmm ssss1))
392.   (if plmm (ssadd plmm ssss2))
393.   (if plmm (ssadd plmm ssss3))
394.   (if plmm (ssadd plmm ssss4))
395.   (prompt "\nUpper-right 2d polyline is highlighted - ENTER TO CONTINUE")
398.   (setq llpls nil)
399.   (command "\\")
400.
401.   (setq i -1)
402.   (command "_.ucs" "z" 90)
403.   (while (setq pl (ssname ssss1 (setq i (1+ i))))
404.     (setq vlst (plvlst pl))
405.     (if (LM:ListClockwise-p vlst)
406.         (command "_.reverse" pl "")
407.         (setq vlst (plvlst pl))
408.       )
409.     )
410.     (if (llchk vlst) (setq llpls (cons pl llpls)))
411.   )
412.   (foreach plll (reverse llpls)
413.     (ssdel plll ssss1)
414.     (ssdel plll ssss2)
415.     (ssdel plll ssss3)
416.     (ssdel plll ssss4)
417.     (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
418.     (setq wchk1 (if (eq (car (setq plnn (llwidchk plll ssss1 len))) T) (progn (setq plnn (cadr plnn)) T) nil))
419.     (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
420.     (setq wchk2 (if (eq (car (setq plnn (llwidchk plll (setq sss (reversess ssss2)) len))) T) (progn (setq plnn (cadr plnn)) T) nil))
421.     (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
422.     (setq lchk1 (if (eq (car (lllenchk plll ssss3 wid)) T) T nil))
423.     (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
424.     (setq lchk2 (if (eq (car (lllenchk plll (setq sss (reversess ssss4)) wid)) T) T nil))
425.     (if (and
426.           (or wchk1 wchk2)
427.           (or lchk1 lchk2)
428.         )
429.         (setq llpl plll)
430.     )
431.     (setq wchk1 nil wchk2 nil lchk1 nil lchk2 nil)
433.     (setq i -1)
434.     (while (setq pl (ssname ss (setq i (1+ i))))
439.     )
440.   )
441.   (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
442.   (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
443.   (prompt "\nUpper-left 2d polyline is highlighted - ENTER TO CONTINUE")
446.   (setq llpls nil)
447.   (command "\\")
448.
449.   (command "_.ucs" "w")
450.   (prompt "\nAll corner 2d polylines are highlighted")
451.   (sssetfirst nil ssss)
452.
453.   (princ)
454. )
455.

Regards, Marko Ribar
« Last Edit: June 22, 2013, 11:32:28 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture) #### ribarm ##### Re: ==={Challenge}=== Broken Pieces
« Reply #38 on: June 22, 2013, 10:02:12 AM »
Now almost work and with my *-MR4.dwg... See attachment... It fails to obtain 4th piece...

But I think the code is OK for now - think it can't be developed too much more...   M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture) #### ribarm ##### Re: ==={Challenge}=== Broken Pieces
« Reply #39 on: June 22, 2013, 11:34:47 AM »
Now works and with *-MR4.dwg... I think that's all - no more intervention... In most cases if it can find first piece, then it should find all other as well...
Marko Ribar, d.i.a. (graduated engineer of architecture) #### ribarm ##### Re: ==={Challenge}=== Broken Pieces
« Reply #40 on: June 23, 2013, 01:40:00 PM »
My last modification - every piece has to be different shape straight 2d polyline... It works on my *-MR4.dwg... No more ENTER between UCS rotations... If it finds solution all 4 pieces - corners are highlighted... Each solution is obtained by iterating through entities that pass firstly check of lower-left angle of 90 degrees...

Code - Auto/Visual Lisp: [Select]
1. (defun c:putmetogether ( / AssocOn LM:ListClockwise-p member-fuzz plvlst llchk prevang nextang suppang anglst dstlst mdpairs reversess dstangchk llwidchk lllenchk putme
2.                            p1 p2 vec ss s sssss loop ssss1 ssss2 ssss3 ssss4 wid len i pl vlst llpls llplss plll llpl plnn plmm )
3.
4.
5.   (defun AssocOn ( SearchTerm Lst func fuzz )
6.     (car
7.       (vl-member-if
8.           (lambda (pair) (equal SearchTerm (apply func (list pair)) fuzz))
9.         )
10.         lst
11.       )
12.     )
13.   )
14.
15.   (defun LM:ListClockwise-p ( lst )
16.       (apply '+
17.             (lambda ( a b )
18.               (- (* (car b) (cadr a)) (* (car a) (cadr b)))
19.             )
20.           ) lst (cons (last lst) lst)
21.         )
22.       )
23.     )
24.   )
25.
26.   (defun member-fuzz ( expr lst fuzz )
27.     (while (and lst (not (equal (car lst) expr fuzz)))
28.       (setq lst (cdr lst))
29.     )
30.     lst
31.   )
32.
33.   (defun plvlst ( pl / vlst pt ptlst )
34.     (setq vlst (vlax-safearray->list (vlax-variant-value (vla-get-coordinates (vlax-ename->vla-object pl)))))
35.     (cond
36.       ( (eq (vla-get-objectname (vlax-ename->vla-object pl)) "AcDbPolyline")
37.         (repeat (/ (length vlst) 2)
38.           (setq pt (list (car vlst) (cadr vlst)))
39.           (setq vlst (cddr vlst))
40.           (setq ptlst (cons pt ptlst))
41.         )
42.         (mapcar '(lambda (x) (trans x 0 1)) (reverse ptlst))
43.       )
44.       ( (eq (vla-get-objectname (vlax-ename->vla-object pl)) "AcDb2dPolyline")
45.         (repeat (/ (length vlst) 3)
46.           (setq pt (list (car vlst) (cadr vlst)))
47.           (setq vlst (cdddr vlst))
48.           (setq ptlst (cons pt ptlst))
49.         )
50.         (mapcar '(lambda (x) (trans x 0 1)) (reverse ptlst))
51.       )
52.     )
53.   )
54.
55.   (defun llchk ( lst / tst )
56.     (mapcar '(lambda (a b c)
57.                (if (and (equal (angle a b) 0.0 1e-6) (equal (angle c a) (* 1.5 pi) 1e-6)) (setq tst (cons T tst)) (setq tst (cons nil tst)))
58.              )
59.              lst
60.              (append (cdr lst) (list (car lst)))
61.              (append (list (last lst)) (reverse (cdr (reverse lst))))
62.     )
63.     (eval (cons 'or tst))
64.   )
65.
66.   (defun prevang ( ang lst / alst )
67.     (setq alst (anglst lst))
68.     (cond
69.       ( (equal ang (car alst) 1e-6)
70.         (last alst)
71.       )
72.       ( (equal ang (last alst) 1e-6)
74.       )
75.       ( (cadr (member-fuzz ang (reverse alst) 1e-6)) )
76.     )
77.   )
78.
79.   (defun nextang ( ang lst / alst )
80.     (setq alst (anglst lst))
81.     (cond
82.       ( (equal ang (car alst) 1e-6)
84.       )
85.       ( (equal ang (last alst) 1e-6)
86.         (car alst)
87.       )
88.       ( (cadr (member-fuzz ang alst 1e-6)) )
89.     )
90.   )
91.
92.   (defun suppang ( ang )
93.     (cond
94.       ( (< 0.0 ang pi)
95.         (+ ang pi)
96.       )
97.       ( (< pi ang (* 2.0 pi))
98.         (- ang pi)
99.       )
100.       ( (equal ang pi 1e-6)
101.         0.0
102.       )
103.       ( (or (equal ang 0.0 1e-6) (equal ang (* 2.0 pi) 1e-6))
104.         pi
105.       )
106.     )
107.   )
108.
109.   (defun anglst ( lst / alst )
110.     (setq alst (mapcar '(lambda (a b) (angle a b)) lst (append (cdr lst) (list (car lst)))))
111.   )
112.
113.   (defun dstlst ( lst / dlst )
114.     (setq dlst (mapcar '(lambda (a b) (distance a b)) lst (append (cdr lst) (list (car lst)))))
115.   )
116.
117.   (defun mdpairs ( lst1 lst2 )
118.     (mapcar '(lambda (a b) (cons a b)) lst1 lst2)
119.   )
120.
121.   (defun reversess ( s / sx i ent )
123.     (repeat (setq i (sslength s))
124.       (setq ent (ssname s (setq i (1- i))))
126.     )
127.     sx
128.   )
129.
130.   (defun dstangchk ( d a ss / i e pairs elst )
131.     (setq i -1)
132.     (while (setq e (ssname ss (setq i (1+ i))))
133.       (setq pairs (mdpairs (anglst (plvlst e)) (dstlst (plvlst e))))
134.       (if (equal d (cdr (assocon a pairs 'car 1e-6)) 1e-6)
135.         (setq elst (cons e elst))
136.       )
137.     )
138.     elst
139.   )
140.
141.   (defun llwidchk ( llpl sss wid / flag an sn dn )
142.     (setq vlstw (plvlst llpl))
143.     (setq alstw (anglst vlstw))
144.     (if (not angn) (setq angn (nextang 0.0 vlstw)))
145.     (if (not suppangn) (setq suppangn (suppang angn)))
146.     (if (not llplwid) (setq llplwid (cdr (assocon 0.0 (mdpairs alstw (dstlst vlstw)) 'car 1e-6))))
147.     (if (not lwid) (setq lwid llplwid))
148.     (if (not dstnn) (setq dstnn (cdr (assocon angn (mdpairs alstw (dstlst vlstw)) 'car 1e-6))))
149.     (setq plns (dstangchk dstnn suppangn sss))
150.     (if plns
151.         (foreach pln plns
152.           (setq plnwid (cdr (assocon 0.0 (mdpairs (anglst (plvlst pln)) (dstlst (plvlst pln))) 'car 1e-6)))
153.           (setq dstnn (cdr (assocon (nextang 0.0 (plvlst pln)) (mdpairs (anglst (plvlst pln)) (dstlst (plvlst pln))) 'car 1e-6)))
154.           (if (nextang 0.0 (plvlst pln)) (setq angn (nextang 0.0 (plvlst pln))))
155.           (if angn (setq suppangn (suppang angn)))
156.           (if (and plnwid dstnn (not flag))
157.             (setq lwid (+ lwid plnwid) npl pln an angn sn suppangn dn dstnn flag T)
158.           )
159.         )
160.         (if (and an sn dn) (setq angn an suppangn sn dstnn dn))
161.         (if (equal lwid wid 1e-6) (setq chk T plx npl)
162.           (if (< lwid wid)
163.               (if (not flag) (setq npl (car plns)))
164.               (if (and npl flag)
165.                 (llwidchk npl (ssdel npl sss) wid)
166.                   (setq suppangn (suppang (setq angn (nextang suppangn (plvlst npl)))))
167.                   (setq dstnn (cdr (assocon angn (mdpairs (anglst (plvlst npl)) (dstlst (plvlst npl))) 'car 1e-6)))
168.                   (llwidchk npl (ssdel npl sss) wid)
169.                 )
170.               )
171.             )
172.           )
173.         )
174.       )
175.     )
176.     (list chk plx)
177.   )
178.
179.   (defun lllenchk ( llpl sss len / flag ap sp dp )
180.     (setq vlstl (plvlst llpl))
181.     (setq alstl (anglst vlstl))
182.     (if (not angp) (setq angp (prevang (* 1.5 pi) vlstl)))
183.     (if (not suppangp) (setq suppangp (suppang angp)))
184.     (if (not llpllen) (setq llpllen (cdr (assocon (* 1.5 pi) (mdpairs alstl (dstlst vlstl)) 'car 1e-6))))
185.     (if (not llen) (setq llen llpllen))
186.     (if (not dstpp) (setq dstpp (cdr (assocon angp (mdpairs alstl (dstlst vlstl)) 'car 1e-6))))
187.     (setq plps (dstangchk dstpp suppangp sss))
188.     (if plps
189.         (foreach plp plps
190.           (setq plplen (cdr (assocon (* 1.5 pi) (mdpairs (anglst (plvlst plp)) (dstlst (plvlst plp))) 'car 1e-6)))
191.           (setq dstpp (cdr (assocon (prevang (* 1.5 pi) (plvlst plp)) (mdpairs (anglst (plvlst plp)) (dstlst (plvlst plp))) 'car 1e-6)))
192.           (if (prevang (* 1.5 pi) (plvlst plp)) (setq angp (prevang (* 1.5 pi) (plvlst plp))))
193.           (if angp (setq suppangp (suppang angp)))
194.           (if (and plplen dstpp (not flag))
195.             (setq llen (+ llen plplen) ppl plp ap angp sp suppangp dp dstpp flag T)
196.           )
197.         )
198.         (if (and ap sp dp) (setq angp ap suppangp sp dstpp dp))
199.         (if (equal llen len 1e-6) (setq chk T ply ppl)
200.           (if (< llen len)
201.               (if (not flag) (setq ppl (car plps)))
202.               (if (and ppl flag)
203.                 (lllenchk ppl (ssdel ppl sss) len)
204.                   (setq suppangp (suppang (setq angp (prevang suppangp (plvlst ppl)))))
205.                   (setq dstpp (cdr (assocon angp (mdpairs (anglst (plvlst ppl)) (dstlst (plvlst ppl))) 'car 1e-6)))
206.                   (lllenchk ppl (ssdel ppl sss) len)
207.                 )
208.               )
209.             )
210.           )
211.         )
212.       )
213.     )
214.     (list chk ply)
215.   )
216.
217.   (defun putme ( plll ss / ssss )
218.
219.     (command "_.ucs" "w")
222.     (setq i -1)
223.     (while (setq pl (ssname ss (setq i (1+ i))))
228.     )
229.     (ssdel plll ssss1)
230.     (ssdel plll ssss2)
231.     (ssdel plll ssss3)
232.     (ssdel plll ssss4)
233.     (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
234.     (setq wchk1 (if (eq (car (setq plnn (llwidchk plll ssss1 wid))) T) (progn (setq plnn (cadr plnn)) T) nil))
235.     (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
236.     (setq wchk2 (if (eq (car (setq plnn (llwidchk plll (setq sss (reversess ssss2)) wid))) T) (progn (setq plnn (cadr plnn)) T) nil))
237.     (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
238.     (setq lchk1 (if (eq (car (setq plmm (lllenchk plll ssss3 len))) T) (progn (setq plmm (cadr plmm)) T) nil))
239.     (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
240.     (setq lchk2 (if (eq (car (setq plmm (lllenchk plll (setq sss (reversess ssss4)) len))) T) (progn (setq plmm (cadr plmm)) T) nil))
241.     (if (and
242.           (or wchk1 wchk2)
243.           (or lchk1 lchk2)
244.         )
245.         (setq llpl plll)
246.     )
247.     (setq wchk1 nil wchk2 nil lchk1 nil lchk2 nil)
249.     (setq i -1)
250.     (while (setq pl (ssname ss (setq i (1+ i))))
255.     )
256.     (if plnn (ssdel plnn ssss1))
257.     (if plnn (ssdel plnn ssss2))
258.     (if plnn (ssdel plnn ssss3))
259.     (if plnn (ssdel plnn ssss4))
260.     (if plnn (ssadd plnn ssss1))
261.     (if plnn (ssadd plnn ssss2))
262.     (if plnn (ssadd plnn ssss3))
263.     (if plnn (ssadd plnn ssss4))
266.     (setq llpls nil)
267.
268.     (setq i -1)
269.     (command "_.ucs" "z" 90)
270.     (while (setq pl (ssname ssss1 (setq i (1+ i))))
271.       (setq vlst (plvlst pl))
272.       (if (LM:ListClockwise-p vlst)
273.           (command "_.reverse" pl "")
274.           (setq vlst (plvlst pl))
275.         )
276.       )
277.       (if (llchk vlst) (setq llpls (cons pl llpls)))
278.     )
279.     (foreach plll (reverse llpls)
280.       (ssdel plll ssss1)
281.       (ssdel plll ssss2)
282.       (ssdel plll ssss3)
283.       (ssdel plll ssss4)
284.       (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
285.       (setq wchk1 (if (eq (car (setq plnn (llwidchk plll ssss1 len))) T) (progn (setq plnn (cadr plnn)) T) nil))
286.       (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
287.       (setq wchk2 (if (eq (car (setq plnn (llwidchk plll (setq sss (reversess ssss2)) len))) T) (progn (setq plnn (cadr plnn)) T) nil))
288.       (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
289.       (setq lchk1 (if (eq (car (lllenchk plll ssss3 wid)) T) T nil))
290.       (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
291.       (setq lchk2 (if (eq (car (lllenchk plll (setq sss (reversess ssss4)) wid)) T) T nil))
292.       (if (and
293.             (or wchk1 wchk2)
294.             (or lchk1 lchk2)
295.           )
296.           (setq llpl plll)
297.       )
298.       (setq wchk1 nil wchk2 nil lchk1 nil lchk2 nil)
300.       (setq i -1)
301.       (while (setq pl (ssname ss (setq i (1+ i))))
306.       )
307.     )
308.     (if plnn (ssdel plnn ssss1))
309.     (if plnn (ssdel plnn ssss2))
310.     (if plnn (ssdel plnn ssss3))
311.     (if plnn (ssdel plnn ssss4))
312.     (if plnn (ssadd plnn ssss1))
313.     (if plnn (ssadd plnn ssss2))
314.     (if plnn (ssadd plnn ssss3))
315.     (if plnn (ssadd plnn ssss4))
318.     (setq llpls nil)
319.
320.     (setq i -1)
321.     (command "_.ucs" "z" 90)
322.     (while (setq pl (ssname ssss1 (setq i (1+ i))))
323.       (setq vlst (plvlst pl))
324.       (if (LM:ListClockwise-p vlst)
325.           (command "_.reverse" pl "")
326.           (setq vlst (plvlst pl))
327.         )
328.       )
329.       (if (llchk vlst) (setq llpls (cons pl llpls)))
330.     )
331.     (foreach plll (reverse llpls)
332.       (ssdel plll ssss1)
333.       (ssdel plll ssss2)
334.       (ssdel plll ssss3)
335.       (ssdel plll ssss4)
336.       (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
337.       (setq wchk1 (if (eq (car (setq plnn (llwidchk plll ssss1 wid))) T) (progn (setq plnn (cadr plnn)) T) nil))
338.       (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
339.       (setq wchk2 (if (eq (car (setq plnn (llwidchk plll (setq sss (reversess ssss2)) wid))) T) (progn (setq plnn (cadr plnn)) T) nil))
340.       (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
341.       (setq lchk1 (if (eq (car (lllenchk plll ssss3 len)) T) T nil))
342.       (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
343.       (setq lchk2 (if (eq (car (lllenchk plll (setq sss (reversess ssss4)) len)) T) T nil))
344.       (if (and
345.             (or wchk1 wchk2)
346.             (or lchk1 lchk2)
347.           )
348.           (setq llpl plll)
349.       )
350.       (setq wchk1 nil wchk2 nil lchk1 nil lchk2 nil)
352.       (setq i -1)
353.       (while (setq pl (ssname ss (setq i (1+ i))))
358.       )
359.     )
360.     (if plnn (ssdel plnn ssss1))
361.     (if plnn (ssdel plnn ssss2))
362.     (if plnn (ssdel plnn ssss3))
363.     (if plnn (ssdel plnn ssss4))
364.     (if plnn (ssadd plnn ssss1))
365.     (if plnn (ssadd plnn ssss2))
366.     (if plnn (ssadd plnn ssss3))
367.     (if plnn (ssadd plnn ssss4))
368.     (if plmm (ssdel plmm ssss1))
369.     (if plmm (ssdel plmm ssss2))
370.     (if plmm (ssdel plmm ssss3))
371.     (if plmm (ssdel plmm ssss4))
372.     (if plmm (ssadd plmm ssss1))
373.     (if plmm (ssadd plmm ssss2))
374.     (if plmm (ssadd plmm ssss3))
375.     (if plmm (ssadd plmm ssss4))
378.     (setq llpls nil)
379.
380.     (setq i -1)
381.     (command "_.ucs" "z" 90)
382.     (while (setq pl (ssname ssss1 (setq i (1+ i))))
383.       (setq vlst (plvlst pl))
384.       (if (LM:ListClockwise-p vlst)
385.           (command "_.reverse" pl "")
386.           (setq vlst (plvlst pl))
387.         )
388.       )
389.       (if (llchk vlst) (setq llpls (cons pl llpls)))
390.     )
391.     (foreach plll (reverse llpls)
392.       (ssdel plll ssss1)
393.       (ssdel plll ssss2)
394.       (ssdel plll ssss3)
395.       (ssdel plll ssss4)
396.       (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
397.       (setq wchk1 (if (eq (car (setq plnn (llwidchk plll ssss1 len))) T) (progn (setq plnn (cadr plnn)) T) nil))
398.       (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
399.       (setq wchk2 (if (eq (car (setq plnn (llwidchk plll (setq sss (reversess ssss2)) len))) T) (progn (setq plnn (cadr plnn)) T) nil))
400.       (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
401.       (setq lchk1 (if (eq (car (lllenchk plll ssss3 wid)) T) T nil))
402.       (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
403.       (setq lchk2 (if (eq (car (lllenchk plll (setq sss (reversess ssss4)) wid)) T) T nil))
404.       (if (and
405.             (or wchk1 wchk2)
406.             (or lchk1 lchk2)
407.           )
408.           (setq llpl plll)
409.       )
410.       (setq wchk1 nil wchk2 nil lchk1 nil lchk2 nil)
412.       (setq i -1)
413.       (while (setq pl (ssname ss (setq i (1+ i))))
418.       )
419.     )
420.     (setq vlstw nil alstw nil angn nil suppangn nil llplwid nil lwid nil dstnn nil plnwid nil plns nil npl nil chk nil plx nil)
421.     (setq vlstl nil alstl nil angp nil suppangp nil llpllen nil llen nil dstpp nil plplen nil plps nil ppl nil chk nil ply nil)
424.     (setq llpls nil)
425.
426.     ssss
427.   )
428.
429.   (command "_.ucs" "w")
430.   (setq ss (ssget "_:L" '((0 . "*POLYLINE") (-4 . "&=") (70 . 1))))
431.   (setq p1 (getpoint "\nPick start corner : "))
432.   (setq p2 (getcorner p1 "\nPick end corner : "))
433.   (setq vec (mapcar '- p2 p1))
434.   (setq wid (abs (car vec)))
435.   (setq len (abs (cadr vec)))
436.
437.   (command "_.ucs" "w")
438.   (setq i -1)
439.   (while (setq pl (ssname ss (setq i (1+ i))))
440.     (setq vlst (plvlst pl))
441.     (if (LM:ListClockwise-p vlst)
442.         (command "_.reverse" pl "")
443.         (setq vlst (plvlst pl))
444.       )
445.     )
446.     (if (llchk vlst) (setq llplss (cons pl llplss)))
447.   )
448.   (setq loop T)
449.   (while (and (setq plll (car llplss)) loop)
450.     (if (eq (vl-catch-all-apply 'sslength (list (setq s (vl-catch-all-apply 'putme (list plll ss))))) 4)
452.         (ssadd (ssname s 0) sssss)
453.         (ssadd (ssname s 1) sssss)
454.         (ssadd (ssname s 2) sssss)
455.         (ssadd (ssname s 3) sssss)
456.       )
458.     )
459.     (sssetfirst nil sssss)
460.     (if (eq (getstring "\nENTER TO CONTINUE (NEXT SOLUTION) - A KEY+ENTER TO EXIT AND KEEP SOLUTION : ") "")
461.       (setq llplss (cdr llplss))
462.       (setq loop nil)
463.     )
464.   )
465.   (command "_.ucs" "w")
466.   (if sssss (sssetfirst nil sssss))
467.
468.   (princ)
469. )
470.

M.R.
« Last Edit: June 23, 2013, 04:38:03 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture) #### ribarm ##### Re: ==={Challenge}=== Broken Pieces
« Reply #41 on: June 23, 2013, 04:42:46 PM »
My last code is modified to be applicable for all candidate entities that passes check of lower-left angle of 90 degrees... It is now iterating through list of all these entities... When desired solution is found, you have option to keep selected entities...
Marko Ribar, d.i.a. (graduated engineer of architecture) #### ribarm ##### Re: ==={Challenge}=== Broken Pieces
« Reply #42 on: June 24, 2013, 09:41:08 AM »
Although I suggest that you use my last code, here are 2 lisps developed further more, but with many lacks...

Picking version is correct, but it is totally unnecessary, as you can pick entities and you'll have them griped and without routine...
Pick version is longest developed, it asks for starting lower-left piece, result correct and for *-MR5.dwg...

Both codes are time consuming, but who likes it to see them testing here they are... See attachment...

M.R.
« Last Edit: June 24, 2013, 02:24:13 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture) #### ribarm ##### Re: ==={Challenge}=== Broken Pieces
« Reply #43 on: June 24, 2013, 02:26:04 PM »
Finally modified my attached lisp - pick version to be applicable and for case like *-MR5.dwg - see attachment...

Regards, yours M.R.   Marko Ribar, d.i.a. (graduated engineer of architecture) #### ribarm ##### Re: ==={Challenge}=== Broken Pieces
« Reply #44 on: July 06, 2013, 10:33:49 AM »
This site allows posting of too large codes...    