Results 1 to 4 of 4

Thread: Circle Sortings

  1. #1
    100 Club
    Join Date
    2011-08
    Location
    Vadodara, India
    Posts
    142
    Login to Give a bone
    0

    Default Circle Sortings

    Hi!

    I have some circles in polygon, I have a routine for sorting X-direction from left to right. I need also sorting Right to Left direction.

    Attached my routine for left to right direction.

    Code:
    (defun bns_esort (ss func / a lst e1 na n)
      (setq ss2 (ssadd))      ;setq
      (setq n 0)
      (repeat (sslength ss)
        (setq na (ssname ss n)
        e1 (entget na)
        )         ;setq
              ;(setq lst (append lst
              ;                  (list (list (eval '(func e1))
              ;                              e1
              ;                        );list
              ;                  );list
              ;          );append
              ;);setq
        (setq lst (cons (list (eval '(func e1)) e1)
            lst
            )       ;cons
        )         ;setq
    
        (setq n (+ n 1))      ;setq
      )         ;repeat
    
      (setq lst (acet-list-isort lst 0))  ;setq
    
      (setq n 0)
      (repeat (length lst)
        (setq a   (nth n lst)
        a   (cadr a)
        a   (cdr (assoc -1 a))
        ss2 (ssadd a ss2)
        )         ;setq
        (setq n (+ n 1))      ;setq
      )         ;repeat
      ss2
    
    ) 
    Avinash
    Attached Images Attached Images

  2. #2
    I could stop if I wanted to
    Join Date
    2003-07
    Posts
    470
    Login to Give a bone
    0

    Default Re: Circle Sortings

    Look into the VL-sort command it can have a > or a < which is left-right right-left etc.

    Something like this
    Code:
    (setq ptlist 
    (vl-sort ptlist 
    '(lambda (x y)
    (cond
    ((= (cadr x)(cadr y))
    (< (car x)(car y)))
    ((< (cadr x)(cadr y)))
    )
    )
    )
    )

  3. #3
    100 Club
    Join Date
    2011-08
    Location
    Vadodara, India
    Posts
    142
    Login to Give a bone
    0

    Default Re: Circle Sortings

    not working, I have a list like...
    ((41.0 -25.0 0.0) (41.0 -72.6802 0.0) (26.0 -135.311 0.0) (33.025 -384.687 0.0) (41.0 -637.0 0.0) (33.025 -914.667 0.0) (41.0 -1248.24 0.0) (41.0 -1308.24 0.0) (29.028 -1599.86 0.0) (41.0 -1870.24 0.0) (33.025 -2086.43 0.0) (26.0 -2409.17 0.0) (33.0 -2452.83 0.0) (45.0 -2493.15 0.0) (26.0 -2493.15 0.0) (25.0 -29.0 0.0) (25.0 -29.0 0.0))

  4. #4
    All AUGI, all the time Tharwat's Avatar
    Join Date
    2010-06
    Posts
    929
    Login to Give a bone
    0

    Default Re: Circle Sortings

    Here you go.

    Code:
    (setq lst '((41.0 -25.0 0.0) (41.0 -72.6802 0.0) (26.0 -135.311 0.0) (33.025 -384.687 0.0)
                (41.0 -637.0 0.0) (33.025 -914.667 0.0) (41.0 -1248.24 0.0) (41.0 -1308.24 0.0)
                (29.028 -1599.86 0.0) (41.0 -1870.24 0.0) (33.025 -2086.43 0.0) (26.0 -2409.17 0.0)
                (33.0 -2452.83 0.0) (45.0 -2493.15 0.0) (26.0 -2493.15 0.0) (25.0 -29.0 0.0) (25.0 -29.0 0.0)))
    
    (setq srt:lst (vl-sort lst '(lambda (a b) (> (car a) (car b)))))

Similar Threads

  1. 2014: Creating circle within a circle hatch
    By Ghostly AF in forum AutoCAD Customization
    Replies: 5
    Last Post: 2013-06-13, 08:03 PM
  2. How to Constrain circle with another circle
    By ljupadhyay in forum Revit Architecture - Families
    Replies: 10
    Last Post: 2010-10-05, 03:12 PM
  3. Dimension from face of circle to face of circle?
    By ljlange in forum Revit Architecture - General
    Replies: 1
    Last Post: 2009-10-18, 04:45 PM
  4. Distance from circle to circle
    By Brian.164262 in forum AutoLISP
    Replies: 8
    Last Post: 2008-04-24, 05:31 PM
  5. Circle Polyline (ie Circle with Width)
    By johan d in forum AutoCAD General
    Replies: 4
    Last Post: 2006-02-03, 11:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •