Visual LISP, AutoLISP and General Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Repeating Break at Single Point
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi All,
I'm creating the following macro:- (defun C:BK () (command "_BREAK" PAUSE "_F" PAUSE "@" )(princ)) to add to a shortcut key lisp file and then I want it to repeat... How do I make it repeat?
I want it to do the same as this:- *^C^C_break \_f \@ but as a shortcut key in a lisp format.
Cheers,
Andy
Re: Repeating Break at Single Point
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
andit wrote:....
I'm creating the following macro:- (defun C:BK () (command "_BREAK" PAUSE "_F" PAUSE "@" )(princ)) to add to a shortcut key lisp file and then I want it to repeat... How do I make it repeat?
....
One simple way:
(defun C:BK ()
(while T
(command "_BREAK" PAUSE "_F" PAUSE "@")
)
)
You could add error handling so you wouldn't see the "error: Function cancelled" message when you hit Escape to stop it.
Re: Repeating Break at Single Point
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thankyou Kent that what I was looking for, may I ask how the "(while T" works to repeat the command?
Cheers,
Andy
Re: Repeating Break at Single Point
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Kent1Cooper wrote:
One simple way:
...
You could add error handling so you wouldn't see the "error: Function cancelled" message when you hit Escape to stop it.
Or:
(defun c:bk nil
(while (vl-cmdf "_.break" pause "_F" pause "@")) (princ)
)
(vl-load-com)
So that no error handler is required.
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
Re: Repeating Break at Single Point
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
andit wrote:Thankyou Kent that what I was looking for, may I ask how the "(while T" works to repeat the command?
....
See (while) in the AutoLISP Reference. As long as the 'testexpr' argument doesn't evaluate to nil, it keeps doing what is asked for after that. T is the symbol for True, and never evaluates to nil [unless you commit the crime of using it for a variable name and overriding that]. It could be anything that doesn't, such as
(while 1 (command ....
Re: Repeating Break at Single Point
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Also, you can use one GETPOINT, with or without object snaps, to assign both of the break points.
Re: Repeating Break at Single Point
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Lee_Mac wrote:....Or:
....
(while (vl-cmdf "_.break" pause "_F" pause "@"))
....
So that no error handler is required.
I don't think it would have occurred to me to use a (while) function without any what-to-do-then expression(s) after the test expression, but sure enough, they are optional.
Re: Repeating Break at Single Point
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I've been using this for quite some time, you could just replace the if with while...
(defun c:BA (/ e p)
;; Break Object @ Point
;; Alan J. Thompson, 03.26.09 / 08.23.10
(setvar 'errno 0)
(if (while (and (not e) (/= 52 (getvar 'errno))) (setq e (entsel "\nSelect object to break: ")))
(progn (setq p (cond ((getpoint "\nSpecify point to break @ <Selection Point>: "))
((osnap (cadr e) "_near"))
)
)
(vl-cmdf "_.break" e "_F" "_non" p "_non" p)
)
)
(princ)
)
