motee-z Posted March 28, 2015 Share Posted March 28, 2015 small help please any idea i want to select a certain lines then store endpoints of these lines in a list thaks Quote Link to comment Share on other sites More sharing options...
David Bethel Posted March 28, 2015 Share Posted March 28, 2015 The base engine could look like this : [b][color=BLACK]([/color][/b]defun c:linepl [b][color=FUCHSIA]([/color][/b]/ pl ss i en ed[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget '[b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]0 . [color=#2f4f4f]"LINE"[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq i 0[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]while [b][color=MAROON]([/color][/b]setq en [b][color=GREEN]([/color][/b]ssname ss i[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq ed [b][color=GREEN]([/color][/b]entget en[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]foreach g '[b][color=GREEN]([/color][/b]10 11[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setq pl [b][color=BLUE]([/color][/b]cons [b][color=RED]([/color][/b]cdr [b][color=PURPLE]([/color][/b]assoc g ed[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b] pl[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq i [b][color=GREEN]([/color][/b]1+ i[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]and pl [b][color=MAROON]([/color][/b]alert [b][color=GREEN]([/color][/b]rtos [b][color=BLUE]([/color][/b]length pl[b][color=BLUE])[/color][/b] 2 0[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 28, 2015 Share Posted March 28, 2015 The variable 'lst' holds the list of end coordinates of the selected lines . (defun c:Ends (/ ss lst) (if (setq ss (ssget '((0 . "LINE")))) ((lambda (i / sn) (while (setq sn (ssname ss (setq i (1+ i)))) (setq lst (cons (cdr (assoc 11 (entget sn))) lst)) ) ) -1 ) ) (if lst lst (princ)) ) Quote Link to comment Share on other sites More sharing options...
motee-z Posted March 28, 2015 Author Share Posted March 28, 2015 thank you david thank you tharwat Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 29, 2015 Share Posted March 29, 2015 One thing whilst great code above what happens when you draw a line the other way ? You may want the bit extra like I use about checking which end you pick so swap 10 & 11 answers to get start end as I desire. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted March 29, 2015 Share Posted March 29, 2015 While I use sp (start_pt) & ep ( end_point ) a lot as the point values of lines, AutoCAD really uses From & To prompts and never really designates start and end. The OP never really stated which points were required. ( all line points ) ( pairs of all line points ) ( pairs and their reverse of all line points ) I use the pairs and their reverse a lot ( for an overkill type function ) (defun vld_deldup (/ ss i ll en ed p10 p11 mln) (setq mln 0.003) (princ (strcat "\nSearching " (getvar "CLAYER") "... ")) (and (setq ss (ssget "X" (list (cons 0 "LINE")(cons 8 (getvar "CLAYER"))))) (setq i 0) (while (setq en (ssname ss i)) (setq ed (entget en) p10 (cdr (assoc 10 ed)) p11 (cdr (assoc 11 ed))) (if (or (< (distance p10 p11) mln) (member (list p10 p11) ll) (member (list p11 p10) ll)) (entdel en) (setq ll (cons (list p10 p11) ll))) (setq i (1+ i))) (if ll (princ (strcat (rtos (length ll) 2 0) " Of " (rtos i 2 0) " LINEs Remain")) (princ "- No Duplicates Found"))) (prin1)) Most of the time, I will round the point values to mln Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 29, 2015 Share Posted March 29, 2015 thank you tharwat You are welcome any time . Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted March 30, 2015 Share Posted March 30, 2015 One thing whilst great code above what happens when you draw a line the other way ? You may want the bit extra like I use about checking which end you pick so swap 10 & 11 answers to get start end as I desire. example if OP wants collect points of vertical lines intersect in cross section?, if the first line endpoint facing down side ,the rest offset interval & trimmed lines would inherit the same pattern. Though the OP's example dwg has no issue, i do agree BIGAL's consideration for the direction should be taken in to account. noted 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.