I'm working on, what I call, additional snaps. For example: VirtMid (virtual midpoint) to snap to the midpoint between two points.
: line
ENTER to use last point/Follow/<Start of line>: (vm)
VirtMid: first point:
VirtMid: second point: (6.94611 4.69301 0.0)
ENTER to use last point/Follow/<Start of line>:
Angle/Length/Undo/<End point>:
Angle/Length/Follow/Undo/<End point>:
This works just fine unless there is a running osnap and an entity at the calculated point. If for instance osmode=1 and the two points picked for VirtMid are the endpoints of the same line, the result is one of the endpoints of the line.
This behaviour has recently been adopted by Bricscad for compatibility reasons.
As a workaround I have come up with VirtMid2 which uses a different method to send the point to the command.
: line
ENTER to use last point/Follow/<Start of line>: (vm2)
VirtMid: first point:
VirtMid: second point:
ENTER to use last point/Follow/<Start of line>: _none
Angle/Length/Undo/<End point>:
Angle/Length/Follow/Undo/<End point>:
The biggest disadvantage of this workaround is that you can no longer stack additional snaps. Of course it also looks ugly.
I've tried switching off osmode in the usual way (see VirtMid3) but that doesn't work.
So my question is:
Is there another way to bypass the running osnaps?
(defun VM () (VirtMid))
(defun VirtMid ( / pt1 pt2)
(if
(and
(setq pt1 (getpoint "\nVirtMid: first point: "))
(setq pt2 (getpoint pt1 "\nVirtMid: second point: "))
)
(MidPoint pt1 pt2)
)
)
(defun VM2 () (VirtMid2))
(defun VirtMid2 ( / pt1 pt2)
(if
(and
(setq pt1 (getpoint "\nVirtMid: first point: "))
(setq pt2 (getpoint pt1 "\nVirtMid: second point: "))
)
(command "_none" (MidPoint pt1 pt2))
)
(princ)
)
(defun VM3 () (VirtMid3))
(defun VirtMid3 ( / pt1 pt2 oldOsmode)
(setq oldOsmode (getvar "osmode"))
(if
(and
(setq pt1 (getpoint "\nVirtMid: first point: "))
(setq pt2 (getpoint pt1 "\nVirtMid: second point: "))
)
(progn
(setvar "osmode" 0)
(MidPoint pt1 pt2)
(setvar "osmode" oldOsmode)
)
)
(princ)
)
(defun MidPoint (pt1 pt2)
(mapcar '(lambda (a b) (/ (+ a b) 2.0)) pt1 pt2)
)
(princ "\nUsage: (VM) or (VM2); (VM3) doesn't work... ")
(princ)