Author Topic: Combining lists of point lists  (Read 4935 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Combining lists of point lists
« Reply #15 on: May 20, 2011, 06:31:40 PM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Combining lists of point lists
« Reply #16 on: May 21, 2011, 08:12:39 AM »
An iterative version based on Gile's code:

Code: [Select]
(defun PointGroup ( l / a r x x1 x2 )
  (while (setq x (car l)) (setq l (cdr l))
    (while
      (cond
        ( (setq a (assoc (setq x1 (car x)) l))
          (setq x (append (reverse a) (cdr x)) l (vl-remove a l))
        )
        ( (setq a (assoc (setq x2 (last x)) l))
          (setq x (append x (cdr a)) l (vl-remove a l))
        )
        ( (setq a (assoc x1 (setq l (mapcar 'reverse l))))
          (setq x (append (reverse a) (cdr x)) l (vl-remove a l))
        )
        ( (setq a (assoc x2 l))
          (setq x (append x (cdr a)) l (vl-remove a l))
        )
      )
    )
    (setq r (cons x r))
  )
)

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Combining lists of point lists
« Reply #17 on: May 21, 2011, 08:25:20 AM »
This one seems to work with the list in reply #3.
It's needed to test 4 cases: start and end of a sublist with both start and end of the other ones.

Yes! it does indeed work!

I have a replacement for vl-remove
Code: [Select]
(defun remove (expr lst);;;TonyT or VNesterowski
  (apply 'append (subst nil (list expr) (mapcar 'list lst))))

Thanks for the efforts!  I will study each to make sure I understand the flow.  -Davod
R12 Dos - A2K

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Combining lists of point lists
« Reply #18 on: May 21, 2011, 08:29:32 AM »
One of my early routines. 8-)
http://www.theswamp.org/index.php?topic=10378.msg132096#msg132096

CAB that is a good idea as well.  My program makes a unique temp layer that the 3dpolys are created on.  It could explode them easily and search for all lines on that layer.

Thanks!  -David
R12 Dos - A2K