vernonlee Posted March 24, 2015 Posted March 24, 2015 What is the code that I can add to allow any LISP to repeat the command & stop only after I press ESC or something? Below is a sample LISP for reference. Thanks (defun c:bb ( / oldos ent1 p1) (setq oldos (getvar "osmode")) (setq ent1 (entsel "\nSelect object to break... ")) (setq p1 (getpoint "\nPoint at which to break... ")) (setvar "osmode" 0) (command "break" ent1 "f" p1 "@" "") (setvar "osmode" oldos) (princ "\nBreak at Done") (princ) );end defun c:ba () Quote
hmsilva Posted March 24, 2015 Posted March 24, 2015 (defun c:bb (/ oldos ent1 p1) (setq oldos (getvar "osmode")) (while (and (setq ent1 (entsel "\nSelect object to break... ")) (setq p1 (getpoint "\nPoint at which to break... ")) ) (setvar "osmode" 0) (command "break" ent1 "f" p1 "@" "") (setvar "osmode" oldos) (princ "\nBreak at Done") ) (princ) );end defun c:ba () HTH Henrique Quote
Baber62 Posted March 24, 2015 Posted March 24, 2015 Type the command MULTIPLE on command line press enter then use your lisp Quote
David Bethel Posted March 24, 2015 Posted March 24, 2015 Maybe : [b][color=BLACK]([/color][/b]defun c:bb [b][color=FUCHSIA]([/color][/b] / oldos ent1 p1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq oldos [b][color=NAVY]([/color][/b]getvar [color=#2f4f4f]"osmode"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]setq ent1 [b][color=MAROON]([/color][/b]entsel [color=#2f4f4f]"\nSelect object to break... "[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]initget 1[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq p1 [b][color=MAROON]([/color][/b]getpoint [color=#2f4f4f]"\nPoint at which to break... "[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setvar [color=#2f4f4f]"osmode"[/color] 0[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]command [color=#2f4f4f]"_.BREAK"[/color] ent1 [color=#2f4f4f]"_f"[/color] p1 [color=#2f4f4f]"@"[/color] [color=#2f4f4f]""[/color][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setvar [color=#2f4f4f]"osmode"[/color] oldos[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]princ [color=#2f4f4f]"\nBreak at Done"[/color][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]princ[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] -David Quote
David Bethel Posted March 24, 2015 Posted March 24, 2015 You could probably do away with osmode settings with: (command "_.BREAK" ent1 "_non" p1 "_non" p1) Quote
vernonlee Posted March 24, 2015 Author Posted March 24, 2015 Thanks Henrique & David. I will look at them & see what is the extra code you use to repeat the command. I can just use it to also to apply to other LISP as well following the same location of where you place the code? Thanks Quote
hmsilva Posted March 24, 2015 Posted March 24, 2015 You're welcome, vernonlee! Glad I could help Henrique Quote
BIGAL Posted March 25, 2015 Posted March 25, 2015 Use a While check for pick object (while (entsel) ....) if you pick blank screen it will exit same for esc & I often check for (/= ans Nil) this press Quote
vernonlee Posted March 30, 2015 Author Posted March 30, 2015 Comparing the code, I see that the additional code is this:- (while (initget 1)) (defun c:BB ( / oldos ent1 p1) (setq oldos (getvar "osmode")) [color=red][b](while[/b][/color] (setq ent1 (entsel "\nSelect object to break... ")) [color=red][b](initget 1)[/b][/color] (setq p1 (getpoint "\nPoint at which to break... ")) (setvar "osmode" 0) (command "_.BREAK" ent1 "_f" p1 "@" "") (setvar "osmode" oldos)) (princ "\nBreak at Done") (princ)[color=red][b])[/b][/color] Quote
vernonlee Posted March 31, 2015 Author Posted March 31, 2015 You could probably do away with osmode settings with: (command "_.BREAK" ent1 "_non" p1 "_non" p1) Hi David, what does this code do? EDIT I replace as suggested & now there is a gap at every break line? Quote
hmsilva Posted March 31, 2015 Posted March 31, 2015 Hi vernonlee, probably David's suggestion was just just to do away with osmode, using the object snap mode "_NONE" inside the command call, instead of store OSMODE, set OSMODE and restore OSMODE (command "_.BREAK" ent1 "_f" "_NONE" p1 "_NONE" "@" "") And in the 'while' function, you must test a function, in David's code, the test function was (setq ent1 (entsel "\nSelect object to break... ")) the 'initget' was just to force the user to enter a point at 'getpoint' function, the flag 1 is to 'Prevents the user from responding to the request by entering only Enter' In the code I have post, I did use two functions to test inside the 'while' function, (and (setq ent1 (entsel "\nSelect object to break... ")) (setq p1 (getpoint "\nPoint at which to break... ")) ) to allow the user to exit the loop in any of the functions. Without setting OSMODE, your code might be something like this (defun c:bb (/ ent1 p1) (while (and (setq ent1 (entsel "\nSelect object to break... ")) (setq p1 (getpoint "\nPoint at which to break... ")) ) (command "_.BREAK" ent1 "_f" "_NONE" p1 "_NONE" "@" "") (princ "\nBreak at Done") ) (princ) );end defun c:ba () Henrique Quote
vernonlee Posted April 2, 2015 Author Posted April 2, 2015 Wow. Thanks for the break down in explanation Henrique. That is very helpful. Quote
vernonlee Posted April 2, 2015 Author Posted April 2, 2015 What is the code to put if i want it to snap to INT & END? (command "_.BREAK" ent1 "_f" "[b]_NONE[/b]" p1 "[b]_NONE[/b]" "@" "") Quote
hmsilva Posted April 2, 2015 Posted April 2, 2015 You're welcome, vernonlee Glad I could help... What is the code to put if i want it to snap to INT & END? (command "_.BREAK" ent1 "_f" "[b]_NONE[/b]" p1 "[b]_NONE[/b]" "@" "") >> Read this Henrique Quote
vernonlee Posted April 2, 2015 Author Posted April 2, 2015 Thanks for the guide. Will try it when back after the long weekend Happy Easter. Quote
hmsilva Posted April 2, 2015 Posted April 2, 2015 Thanks for the guide. Will try it when back after the long weekendHappy Easter. Happy Easter, vernonlee! Henrique 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.