j_spawn_h Posted December 28, 2012 Share Posted December 28, 2012 Can someone help me. If i select multiple lines by using ssget. How can I get it to know which line is the first and last line of the selection? Is there a lisp already doing this? I have the code to detect the points just need to know the code to determine the first and last. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 28, 2012 Share Posted December 28, 2012 e.g. (if (setq ss (ssget '((0 . "LINE")))) (progn (setq first-line (ssname ss 0)) (setq last-line (ssname ss (1- (sslength ss)))) ) ) Quote Link to comment Share on other sites More sharing options...
j_spawn_h Posted December 28, 2012 Author Share Posted December 28, 2012 Thanks Tharwat. This did what I asked but it seems I am not as good as I thought. I could not find the mid point of the first line. Could you give a suggestion or help here. Here is what I tried to do. (defun c:matt (/) (setq ss (ssget "_:L" '((0 . "LINE")))) (setq first-line (ssname ss 0)) (setq last-line (ssname ss (1- (sslength ss)))) (command "select" last-line "") (setq ed (entget en)) (setq p10 (cdr (assoc 10 ed))) (setq p11 (cdr (assoc 11 ed))) (setq mpt (mapcar '(lambda (a b) (* (+ a b) 0.5)) p10 p11)) (setq d2d (distance (cdr (reverse p10)) (cdr (reverse p11)))) (setq d1d (/ d2d 12.)) (command "_dimlinear" last-line "-mid") ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 28, 2012 Share Posted December 28, 2012 Thanks Tharwat. This did what I asked but it seems I am not as good as I thought. I could not find the mid point of the first line. Could you give a suggestion or help here. Here is what I tried to do. You're welcome .. Check this out ... (if (setq ss (ssget '((0 . "LINE")))) (progn (setq first-line (ssname ss 0)) (setq mid-point (mapcar '(lambda (q p) (/ (+ q p) 2.)) (cdr (assoc 10 (entget first-line))) (cdr (assoc 11 (entget first-line))) ) ) ) ) Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted December 29, 2012 Share Posted December 29, 2012 Sorry to interfere, but (ssname (ssget "_X") 0) is equivalent to (entlast), so if you want last created object you can use index 0, and if you want first use : (- (sslength (ssget)) 1) as index in ssname function... M.R. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 29, 2012 Share Posted December 29, 2012 If i select multiple lines by using ssget. How can I get it to know which line is the first and last line of the selection? If you window over a set of lines in a selection, what do you classify as being the 'first' & 'last' in the selection? The line nearest the window edge? The line with lowest/highest x/y/z coordinate? The lines as they are ordered in the database? When using a selection mode string other than scanning the entire database ("_X" mode), you cannot rely on the order of the entities in the selection set - the "_X" mode will retrieve entities in the order they appear in the drawing database, i.e. in the order they were created in the drawing. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 30, 2012 Share Posted December 30, 2012 Nice answer Lee re database order, also remember last is actually first, pretty sure the selection set is created by pushing entities into the list so sometimes you need to use the reverse option to get what is actually number 0 in list (yes 0 not 1) makes it easier sometimes to not have to think backwards. Quote Link to comment Share on other sites More sharing options...
j_spawn_h Posted January 2, 2013 Author Share Posted January 2, 2013 That is a good point Lee, but right now it doesn't matter which one is first or last. Good to know if I need to set certain lines. Do any of y'all know a thread to read about changing dimension stuff in lisp. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 3, 2013 Share Posted January 3, 2013 J_spawn_h probably best to start a new thread and elaborate more about the DIM stuff is it part of you line question ? Auto dimensioning ? if so post a dwg the dimensions in the image were done by only picking two points. Quote Link to comment Share on other sites More sharing options...
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.