Code Red > AutoLISP (Vanilla / Visual)

(list compare..in another list..

(1/3) > >>

Andrea:
woo !

I'm trying to figure out how to...but... :ugly:

there it is..
I have a list containing a list...

(("TEST1" "4.2" 2.34")("TEST2" "45.42" 4.34")("TEST3" "4.2" 3.5")("TEST4" "4.4" 2.34"))

all second list have 3 items
eg:

"TEST1" is a text
"4.2" is the X coord
"2.34" is the Y coord.

I need to compare each Y cood with the other to see if some text is at the same Y
and than, strcat all text having the same Y and put it on a another list...

 :cry:  hard for me to explain...

in fact..
I need to select by a crossing or window the text (see picture)
and have to result this.:

("1 test1 ok1" "2 test2 ok2" "3 test3 ok3" "4 test4" "test5 ok5" "6 ok6" "7 test7")

I was wondering doing it with list....but i'm lost now...
maybe my brain cpu is out of memory... :-o

If someone understand what i'm trying to do...
please...dont be shy to submit some suggestions..

thanks.

Tramber:
(("TEST1" "4.2" 2.34")("TEST2" "45.42" 4.34")("TEST3" "4.2" 3.5")("TEST4" "4.4" 2.34"))
seems false.
There are 5 " per pair of parenthesis.

Do you need to compare the Ys from to its near neighbour or to all the others ?
In other words, will you use MEMBER or VL-SORT  ^-^ for exemple ?

And, what's the link to the other list, wich is buit so differently and that I don't understand ?

Jeff_M:
Andrea, Tony Tanzillo posted a SelectionSet re-sort routine on the autodesk newsgroups that will get you most of the way to your goal. Search there for the thread "Selection set re-sort" started on March 23, 2000 by Dan Elkins.

I would just repost it here, but Tony placed a copyright notice in the code and since he does not visit here I thought it best to direct you to it.

Tramber:
Do you want to remove 1 or 2 elements each time you find one having the same Y of the other one ?

Check this :

--- Code: ---(setq l1 '(("TEST1" "4.2" "2.34")("TEST4" "4.4" "6.34")("TEST2" "45.42" "4.34")("TEST3" "4.2" "3.5")))
(setq l2(vl-sort l1(function (lambda (e1 e2)(< (caddr e1) (caddr e2)))))); sorted by Ys
--- End code ---

It sorts the elements, for the next step, I need to understand more before helping.

Tramber:
Then, this code :

--- Code: ---(setq endlA nil endlB nil compt 0)
(repeat(1-(length l2))
  (if(=(caddr(nth compt l2))(caddr(nth(1+ compt)l2)))
    (setq endlA(append endlA(list(nth compt l2))))
    (setq endlB(append endlB(list(nth compt l2)))))
  (setq compt(1+ compt)))
(setq endlB(append endlB(list(last l2))))
endlA  endlB
--- End code ---

will build 2 lists but is not very fast and tightened

Navigation

[0] Message Index

[#] Next page

Go to full version