; catenary.lsp by ymg ;; Modified from a program by Hector Monroy, M.S. Civil Eng. ;(defun c:catenary ( / t0 p p1 p2 x1 x2 y1 y2 h c l a v f xv yv pl x) (setq t0 (getreal "\nTension in the cable(In unit of weight):") p (getreal "\nCable weight per unit length:") p1 (getpoint "\nInitial point:") p2 (getpoint p1 "\nEnd point:") x1 (car p1) x2 (car p2) i (if (< x1 x2) 1.0 -1.0) y1 (cadr p1) y2 (cadr p2) h (- y1 y2) c (/ t0 p) l ( - x2 x1) a (/ h (* 2 c (sinh (/ l (* 2 c))))) v (+ (/ l 2) (* c (arcsinh a))) f (* c (- (cosh (/ v c)) 1)) xv (+ x1 v) yv (- y1 f) pl (list p2) x x2 ) (while (if (< x1 x2) (> x x1) (< x x1)) (setq pl (cons (list x (+ (* c (- (cosh (/ (- x xv) c)) 1)) yv)) pl) x (- x i) ) ) (setq pl (cons p1 pl)) (mk_lwp pl))(defun cosh (a) (/ (+ (exp a)(exp (- a))) 2))(defun sinh (a) (/ (- (exp a)(exp (- a))) 2))(defun arcsinh (a)(log (+ a (sqrt (+ 1.0 (* a a))))));;******************************************************************************;;; mk_lwp by Alan J Thompson ;;; Argument: pl, A list of points (2d or 3d) ;;; Create an LWPolyline at Elevation 0, on Current Layer. ;;; Return: Polyline Object ;;;******************************************************************************;(defun mk_lwp (pl) (vlax-ename->vla-object (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length pl)) '(70 . 0) ) (mapcar '(lambda (p) (cons 10 (trans (list (car p) (cadr p)) 1 0))) pl) ) ) ))