+ Reply to Thread
Page 3 of 3 FirstFirst 1 2 3
Results 21 to 23 of 23
  1. #21
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,736

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by marko_ribar View Post
    My solution is fastest as it was made by Autodesk for exactly these purposes...
    Quote Originally Posted by marko_ribar View Post
    my conclusion was that the best thing is to use already predefined functions... Maybe, you don't agree with me, but to me they do the job fine and more important I think faster then any of above proposed codes...

    (test it and if you disagree reply...)
    I would certainly disagree.

    Many of the acet-* functions only appear faster because they are 'compiled' and hence internally linked & optimised. Disregarding the fact that one cannot be guaranteed that all users will have Express Tools' installed and loaded, (which in itself is a good enough reason in many cases to avoid using such functions in applications, especially those which you plan to distribute), in my opinion many of the Express Tools' functions are poorly written.

    To somewhat explain the results of your 'research', I'm not surprised that you found your code to be far slower, since your 'ss=s1+s2' is needlessly complicated and rather inefficient.

    Consider the following demonstration:

    Test Code:
    Code:
    (defun test ( func / et i lst ss st )
        (while (setq ss (ssget '((0 . "POINT"))))
            (setq lst (cons ss lst))
        )
        (if lst
            (progn
                (setq i 0)
                (princ "\nSelection Set Lengths: ")
                (princ "\n----------------------------------------------")
                (foreach x lst
                    (princ (strcat "\nSelection Set " (itoa (setq i (1+ i))) ": " (itoa (sslength x))))
                )
                (princ "\n----------------------------------------------")
                
                (setq fn (eval func))
                (setq st (getvar 'millisecs))
                (fn lst)
                (setq et (getvar 'millisecs))
                
                (princ (strcat "\n" (vl-symbol-name func) " time: " (itoa (- et st)) " ms"))
                (princ "\n----------------------------------------------")
            )
        )
        (princ)
    )

    The Test:


    Return the union of a list of four Selection Sets of Point entities with sizes 6400, 1600, 400, 100.

    The Functions:


    To provide a fair test, the functions ss-union and LM:ss-union were compiled to a .fas file.

    Code:
    ;; Selection Set Union  -  Lee Mac
    ;; Returns the union of a list of Selection Sets
    
    (defun LM:ss-union ( lst / i out )
        (setq lst (vl-sort lst '(lambda ( a b ) (> (sslength a) (sslength b))))
              out (car lst)
        )
        (foreach ss (cdr lst)
            (repeat (setq i (sslength ss))
                (ssadd (ssname ss (setq i (1- i))) out)
            )
        )
        out
    )
    Code:
    (defun ss-union ( lst )
        (apply 'vl-cmdf (append '("_.select") lst '("")))
        (ssget "_P")
    )
    Code:
    (acet-ss-union <List of Selection Sets>)

    The Results:


    LM:SS-UNION
    Code:
    Command: (test 'LM:ss-union)
    
    Selection Set Lengths:
    ----------------------------------------------
    Selection Set 1: 100
    Selection Set 2: 400
    Selection Set 3: 1600
    Selection Set 4: 6400
    ----------------------------------------------
    LM:SS-UNION time: 94 ms
    ----------------------------------------------
    SS-UNION
    Code:
    Command: (test 'ss-union)
    
    Selection Set Lengths:
    ----------------------------------------------
    Selection Set 1: 100
    Selection Set 2: 400
    Selection Set 3: 1600
    Selection Set 4: 6400
    ----------------------------------------------_.select
    Select objects:   100 found
    
    Select objects:   400 found, 500 total
    
    Select objects:   1600 found, 2100 total
    
    Select objects:   6400 found, 8500 total
    
    Select objects:
    Command:
    SS-UNION time: 78 ms
    ----------------------------------------------
    ACET-SS-UNION
    Code:
    Command: (test 'acet-ss-union)
    
    Selection Set Lengths:
    ----------------------------------------------
    Selection Set 1: 100
    Selection Set 2: 400
    Selection Set 3: 1600
    Selection Set 4: 6400
    ----------------------------------------------_.SELECT
    Select objects:   100 found
    
    Select objects:   400 found, 500 total
    
    Select objects:   1600 found, 2100 total
    
    Select objects:   6400 found, 8500 total
    
    Select objects:
    Command: _.SELECT
    Select objects:   100 found
    
    Select objects:
    Command:
    ACET-SS-UNION time: 94 ms
    ----------------------------------------------
    Notice from the above output that the acet-ss-union function uses the same crude method as my ss-union function, by a call to the 'Select' command, however, the difference in performance is because the acet-ss-union function then calls the 'Select' command a second time to return the set, rather than using the more efficient (ssget "_P").

    Of course, the methods involving a call to the 'Select' command will inevitably always be faster than iterating over the Selection Set in LISP, since any and all iteration of the set is performed by the (presumably) Arx module that operates the 'Select' command.

    However, this difference is only slight, even for very large (and possibly rare) unions, as demonstrated by the following merge of six Selection Sets with sizes 102400, 25600, 6400, 1600, 400 & 100:

    LM:SS-UNION
    Code:
    Command: (test 'LM:ss-union)
    
    Selection Set Lengths:
    ----------------------------------------------
    Selection Set 1: 100
    Selection Set 2: 400
    Selection Set 3: 1600
    Selection Set 4: 6400
    Selection Set 5: 25600
    Selection Set 6: 102400
    ----------------------------------------------
    LM:SS-UNION time: 1201 ms
    ----------------------------------------------
    SS-UNION
    Code:
    Command: (test 'ss-union)
    
    Selection Set Lengths:
    ----------------------------------------------
    Selection Set 1: 100
    Selection Set 2: 400
    Selection Set 3: 1600
    Selection Set 4: 6400
    Selection Set 5: 25600
    Selection Set 6: 102400
    ----------------------------------------------_.select
    Select objects:   100 found
    
    Select objects:   400 found, 500 total
    
    Select objects:   1600 found, 2100 total
    
    Select objects:   6400 found, 8500 total
    
    Select objects:   25600 found, 34100 total
    
    Select objects:   102400 found, 136500 total
    
    Select objects:
    Command:
    SS-UNION time: 780 ms
    ----------------------------------------------
    ACET-SS-UNION
    Code:
    Command: (test 'acet-ss-union)
    
    Selection Set Lengths:
    ----------------------------------------------
    Selection Set 1: 100
    Selection Set 2: 400
    Selection Set 3: 1600
    Selection Set 4: 6400
    Selection Set 5: 25600
    Selection Set 6: 102400
    ----------------------------------------------_.SELECT
    Select objects:   100 found
    
    Select objects:   400 found, 500 total
    
    Select objects:   1600 found, 2100 total
    
    Select objects:   6400 found, 8500 total
    
    Select objects:   25600 found, 34100 total
    
    Select objects:   102400 found, 136500 total
    
    Select objects:
    Command: _.SELECT
    Select objects:   100 found
    
    Select objects:
    Command:
    ACET-SS-UNION time: 811 ms
    ----------------------------------------------
    I would personally argue that this difference is negligible given the aforementioned drawbacks of using the acet-* functions, and furthermore the necessity to modify the CMDECHO System Variable for a 'clean' output following a call to the 'Select' command.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  2. #22
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,106

    Default

    Quote Originally Posted by marko_ribar View Post
    pBe, I've also tried this once on www.augi.com :
    http://forums.augi.com/showthread.ph...functions&p=#1

    ..... my conclusion was that the best thing is to use already predefined functions... Maybe, you don't agree with me, but to me they do the job fine and more important I think faster then any of above proposed codes...
    Thank you for posting the link ,i'm sure the OP will appreciate that. Now as for whats FASTER is not what i'm driving at. But what we can do to help with query the OP posted. This is CAD Tutor after all.

  3. #23
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    Jun 2012
    Posts
    21

    Default

    Registered forum members do not see this ad.

    Perfect! this is what i want to see here - discusions, argues, ideeas... anyhow, i'm the best lisper in the world!
    Thanks to all guys!

Similar Threads

  1. Selection sets in vb.net
    By Jozi68 in forum .NET, ObjectARX & VBA
    Replies: 8
    Last Post: 14th Feb 2012, 07:33 pm
  2. VBA - Selection Sets
    By -KarL- in forum AutoLISP, Visual LISP & DCL
    Replies: 17
    Last Post: 3rd Mar 2009, 10:54 am
  3. VBA - Using IF and selection sets
    By wannabe in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 23rd Oct 2008, 02:09 pm
  4. Little help on selection sets please
    By Galingula in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 17th Apr 2006, 03:39 pm
  5. selection sets..........
    By rajanikrishna in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 14th Nov 2005, 11:32 am

Bookmarks

Posting Permissions

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