wimal Posted April 13, 2015 Posted April 13, 2015 (setq dist1 (distance ppup ppdn1)); distance to point (setq ssdistance(ssadd dist1 ssdistance)); adding to selection set distance (setq dist2 (distance ppup ppdn2)); distance to point (setq ssdistance(ssadd dist2 ssdistance)); adding to selection set distance Quote
Lee Mac Posted April 13, 2015 Posted April 13, 2015 Selection sets can only contain entities - you should use a list to store other data. If you are only looking for the minimum of two distances, simply use: (min (distance ppup ppdn1) (distance ppup ppdn2)) Otherwise, add the distances to a list, and apply the min function across the list: (setq lst (cons dist1 lst) lst (cons dist2 lst) ) (apply 'min lst) Or: (setq lst (cons dist2 (cons dist1 lst))) (apply 'min lst) Or: (setq lst (vl-list* dist2 dist1 lst)) (apply 'min lst) Quote
wimal Posted April 14, 2015 Author Posted April 14, 2015 Thanks a lot. your advise is perfect. Next I want to know the smallest distance position of the list .I mean first item or second or which item?? (To day is the traditional new year day of sri lankan Sinhalese. Happy traditional New year for you.) Quote
BIGAL Posted April 14, 2015 Posted April 14, 2015 smallest distance position this has been asked also recently but if you need to know which section rather than or maybe both minimum do like Lee make a list and use NTH to check the value (nth X lst) is it less than X+1. Running out of time will post example soon. Quote
Lee Mac Posted April 14, 2015 Posted April 14, 2015 Thanks a lot. your advise is perfect. You're welcome! Next I want to know the smallest distance position of the list .I mean first item or second or which item?? Given a list of distances assigned to a variable 'lst', there are various ways to do this - here is one example: (vl-position (apply 'min lst) lst) (To day is the traditional new year day of sri lankan Sinhalese. Happy traditional New year for you.) Happy 'traditional' New Year to you too! Quote
pBe Posted April 14, 2015 Posted April 14, 2015 Thanks a lot. your advise is perfect.Next I want to know the smallest distance position of the list .I mean first item or second or which item?? Sample (setq lst '(150.23 6854.2 23.52 [b]1.0[/b] 68.65)) (vl-position 0 (vl-sort-i lst '<)) 3 or (vl-position (apply 'min lst) lst) 3 Of course if there are duplicates the results are different (setq lst '(150.23 [b]1.0[/b] 6854.2 23.52 [b]1.0[/b] 68.65)) (vl-position 0 (vl-sort-i lst '<)) [b]4[/b] (vl-position (apply 'min lst) lst) [b]1[/b] (setq lst '(150.23 [b]1.0[/b] 6854.2 23.52 [b]1.0[/b] 68.65 [b]1.0[/b])) (vl-position 0 (vl-sort-i lst '<)) [b]5[/b] (vl-position (apply 'min lst) lst) [b]1[/b] So building the data list and and the type of elements should always be put into consideration. EDIT: I did not see LM's post Quote
Lee Mac Posted April 14, 2015 Posted April 14, 2015 Sample(setq lst '(150.23 6854.2 23.52 [b]1.0[/b] 68.65)) (vl-position 0 (vl-sort-i lst '<)) 3 Be careful - this expression only gives the correct result as a coincidence of the example: _$ (setq lst '(150.23 6854.2 23.52 1.0 68.65)) (150.23 6854.2 23.52 1.0 68.65) _$ (vl-position 0 (vl-sort-i lst '<)) 3 _$ (setq lst '(150.23 500.1 6854.2 23.52 1.0 68.65)) (150.23 500.1 6854.2 23.52 1.0 68.65) _$ (vl-position 0 (vl-sort-i lst '<)) 3 If you wish to use vl-sort-i, I would suggest: _$ (setq lst '(150.23 500.1 6854.2 23.52 1.0 68.65)) (150.23 500.1 6854.2 23.52 1.0 68.65) _$ (car (vl-sort-i lst '<)) 4 Quote
pBe Posted April 14, 2015 Posted April 14, 2015 You are right. took me a while to figure out why that works Quote
BIGAL Posted April 15, 2015 Posted April 15, 2015 As usual you guys I had about 15 lines of code and you guys do it with 1 line. The never ending use of VL functions. Quote
wimal Posted April 15, 2015 Author Posted April 15, 2015 OK Thanks everybody for your helping codes. Quote
wimal Posted April 23, 2015 Author Posted April 23, 2015 How can I remove the longest distance from the above list. Quote
Lee Mac Posted April 23, 2015 Posted April 23, 2015 How can I remove the longest distance from the above list. Determine the greatest value using the opposite function (max) with the methods already demonstrated; remove this value using vl-remove or alternatives. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.