;| F2P.lsp -- like M2P but uses *any* fraction instead of just midpoint. F2P returns a point that is a fraction of the way between two specified 2D or 3D points. Although it can be used as a stand-alone command, F2P is intended to be used TRANSPARENTLY in response to any prompt that asks for a point, as below: Command: circle Specify center point for circle or [3P/2P/Ttr (tan tan radius)]: 'F2P F2P: 1st point: _endp of F2P: 2nd point: _endp of F2P: fraction: 7/8 (19.5 30.625 0.0) << starts circle 7/8 of the way from 1st to 2nd Specify radius of circle or [Diameter] <0'-9">: ... The fractional distance between the two points may be expressed as - any FRACTION 1/8, 5/17, -5/2 - any DECIMAL .333, 0.333, 3.5, -2.667, 2.3e-1 but not in AutoLISP format (/ 1 3.0) or in mixed format like 5.2/3 Notes: 1) F2P always returns a 3D point, and works in any UCS. 2) Although the point returned is not affected by the current osnap setting when F2P is used transparently, use of the symbol !F2P in response to subsequent AutoCAD prompts to specify a point will be subject to the osnap setting current at the time of use. 3) The user can ESC from the transparent use of F2P without cancelling the calling command, which is very helpful when you are halfway through a complex 3Dpolyline. (M2P ends the polyline when you ESC.) 4) F2P does not work recursively, i.e, using F2P to define a point to be used by F2P. Neither does M2P, although either can be used to feed points to the other, which can get interesting. by Bill Gilliss bill at realerthanreal dot com Comments and suggestions always welcome. No warranty, either expressed or implied, is made as to the fitness of this information for any particular purpose. All materials are to be considered 'as-is', and use thereof should be considered as at your own risk. ver 1.0 Dec 11 2008 - first incarnation as FRAC.lsp ver 1.1 Dec 17 2008 - modest error handler added - symbol exposed for later use ver 2.0 Feb 12 2010 - program renamed F2P to echo M2P - comments expanded - prompts changed for cleaner interface - OSNAP fixed Keywords: AutoCAD AutoLISP fractional distance ======================================================================== |; (defun c:F2P ( / p1 p2 f myerror olderror) (defun myerror (msg) (setq *error* olderror) (redraw) (setvar 'cmdecho *cmdecho) ) (setq *cmdecho (getvar 'cmdecho)) (setvar 'cmdecho 0) (setq olderror *error*) (setq *error* myerror) (if (= cal nil) (arxload "geomcal")) (setq p1 (getpoint "F2P: 1st point: ")) (initget 32) (setq p2 (getpoint p1 "\nF2P: 2nd point: ")) (grdraw p1 p2 3 1) (setq f (getreal "\nF2P: fraction: ") F2P (c:cal "plt(p1,p2,f)")) ; (grdraw p1 p2 3 1) (if (= 1 (getvar 'cmdactive)) ;; If used transparently, (progn ;; display and return point. (setvar 'cmdecho *cmdecho) (setq *error* myerror) (redraw) (osnap F2P "_none") ) (progn ;; If not, display coordinates (princ ;; in current units. (strcat "Point (" (rtos (car F2P)) " " (rtos (cadr F2P)) " " (rtos (caddr F2P)) ") saved as symbol F2P.") ) (redraw) (princ) ) ) ) (princ "\nF2P loaded. Calculated point will be saved as symbol F2P.") (princ)