florida35 Posted February 20, 2016 Share Posted February 20, 2016 Hi all, I am new to creating lisp routines and am hoping to get some help on a routine I need. I am looking for a command that prompts you to draw a line, then prompts you to extend a line, and then deletes the initial line. I used to work at a company that had this command and it was very useful. Instead of creating a polyline, performing the extend command, and then deleting the polyline, it did all of it in one command. Any help would be greatly appreciated. Thanks. Jim Quote Link to comment Share on other sites More sharing options...
David Bethel Posted February 20, 2016 Share Posted February 20, 2016 (edited) Welcome to CADTutor There are a lot of ways to approach this This would be my starting point : [b][color=BLACK]([/color][/b]defun c:eline [b][color=FUCHSIA]([/color][/b]/ sp ep e1 e2 p1 ip[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]initget 1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq sp [b][color=NAVY]([/color][/b]getpoint [color=#2f4f4f]"\nStart Point: "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]initget 1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq ep [b][color=NAVY]([/color][/b]getpoint sp [color=#2f4f4f]"\nEnd Point: "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]grdraw sp ep 2 0[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]initget 1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq e1 [b][color=NAVY]([/color][/b]getpoint [color=#2f4f4f]"\nExtention Line Point 1: "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]initget 1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq e2 [b][color=NAVY]([/color][/b]getpoint e1 [color=#2f4f4f]"\nExtention Line Point 2: "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]not [b][color=MAROON]([/color][/b]setq ip [b][color=GREEN]([/color][/b]inters sp ep e1 e2 nil[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]alert [color=#2f4f4f]"These Lines Do Not Intersect"[/color][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]progn [b][color=MAROON]([/color][/b]setq p1 [b][color=GREEN]([/color][/b]if [b][color=BLUE]([/color][/b]> [b][color=RED]([/color][/b]distance sp ip[b][color=RED])[/color][/b] [b][color=RED]([/color][/b]distance ep ip[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] sp ep[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]entmake [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"LINE"[/color][b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]cons 10 p1[b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]cons 11 ip[b][color=BLUE])[/color][/b][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] The new line will default to the current entity creation properties. ie LAyer CECcolor CELtype etc -David Edited February 21, 2016 by David Bethel Quote Link to comment Share on other sites More sharing options...
florida35 Posted February 22, 2016 Author Share Posted February 22, 2016 David, I appreciate the quick reply. I was hoping for the extended line to remain part of the original line. Basically, I am hoping for the routine to be very similar to the extend command with just a temporary line added in. I know the command I have seen before worked exactly the same as extend and am hoping to duplicate that. Thanks! Jim Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 22, 2016 Share Posted February 22, 2016 If you explain your aim in more details like image or drawing .. etc and that would help a lot. Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted February 22, 2016 Share Posted February 22, 2016 Hi florida this one? (defun c:extline ( / p1 p2 e) (while (setq p1 (getpoint "\nSpecify first point: ")) (if (setq p2 (getpoint p1 "\nSecond point: ")) (progn (setq e (entmakex (list '(0 . "LINE") (cons 10 p1) (cons 11 p2) ) ) ) (command "_extend" e "") (while (> (getvar 'cmdactive) 0) (command "\\") ) (entdel e) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
florida35 Posted February 23, 2016 Author Share Posted February 23, 2016 Stefan, That is exactly what I was looking for! Thank you so much for your help. Is there any chance you have one for the same command, but using a temporary trim line instead of extend? Thank you all for being so helpful. Jim Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted February 23, 2016 Share Posted February 23, 2016 Stefan, That is exactly what I was looking for! Thank you so much for your help. Is there any chance you have one for the same command, but using a temporary trim line instead of extend? Thank you all for being so helpful. Jim You're welcome Jim. You can replace "_extend" with "_trim" in the lisp above... Or you can hold down Shift when pick the object. Shift temporarily switch Extend to Trim, and vice versa. 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.