@Anonymous wrote:
.... in this case I needed to turn osmode to 55, to select the break points, then reset osmode to the previous setting
I think that 55 as an OSMODE value has one unnecessary mode in it -- CENter. With QUAdrant and MIDpoint and ENDpoint also included, I believe one or another of those will always be closer to the pick point than the CENter of an Arc or Circle or Polyline arc segment. So I think 51 would be operationally identical [used in suggestions below].
You can do that in a not-too-complicated command macro, if you always end its automatic repeating with ESCape when it's asking you to pick an object:
*^C^C(setq osm (getvar 'osmode)) _.break \'osmode 51 _first \\(setvar 'osmode osm)
But if you hit Enter/Space when it's asking you to pick an object, or if you cancel it after picking something but before having picked two break points, you will be left with the OSMODE value of 51 -- it won't reset whatever the value was before.
To ensure that OSMODE gets reset, no matter how the User ends it, you would need a lot more code in an AutoLisp routine with *error* handling, rather than a command macro. Here's a version that extends the allowable objects to all [I think] Breakable types:
(defun C:BF (/ *error* osm esel ent etype); = Break with automatic First option
(defun *error* (errmsg)
(if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
(princ (strcat "\nError: " errmsg))
); if
(setvar 'osmode osm); reset
(princ)
); defun - *error*
(setq osm (getvar 'osmode))
(setvar 'osmode 51)
(while (setq esel (entsel "\nSelect object for First-point Break <exit>: "))
(setq
ent (car esel)
etype (cdr (assoc 0 (entget ent)))
); setq
(if
(and
(wcmatch etype "*LINE,ARC,CIRCLE,ELLIPSE,RAY,TRACE")
; *LINE accepts Line, any kind of Polyline, Spline, and Xline, but we must disallow:
(/= etype "MLINE"); can't be Broken
); and
(command "_break" ent pause pause); then
(prompt "\nCannot Break that object."); else
); if
); while
(setvar 'osmode osm); reset
(princ)
); defun
It could be done with (ssget) and object-type selection filtering, but that always provides its own "Select objects: " prompt, always in the plural, and without the opportunity to display the <exit> default, so I prefer the (entsel) approach in this case.
One other little advantage that has over the command macro approach is that it changes OSMODE only once, and resets it only once, surrounding the entire series of however many Breaks the User does, rather than changing and resetting it separately for every Break.
EDIT: Another little feature that could be added would be for it to ask the User to select something again if they miss in trying to pick something, rather than ending it. As it is, you have the choice to end it by picking where there's nothing, which you may prefer, but if you meant to pick something and missed, it will exit the command -- write back if you'd like to know how to be prompted to pick again instead [and can't figure it out for yourself].
Kent Cooper, AIA