TunzaGibbo 10 Posted June 13 Hi All I'm trying automate a process of placing holes along a rectangle. The drawing enclosed is as far as I can get with Lisp. I have established the 4 corners in my lisp file and are able to place a hole at either end. Where my problem comes into it is that the measurement of 1900 is only for the purpose of this example and could be anything up to 4000. I don't actually know what that measurement is. All I know is that there needs to be a hole 50mm in from each end and then holes spaced equally between these 2 holes with the spacings not to exceed 200mm. Can you give me a hint as to how a formula might work. Possibly something like "if" the distance between the 2 holes than Y Then divide the distance by Z and then write a series of lines to cover all possibilities up to 4000 regards Tony Hole Spacings.pdf Share this post Link to post Share on other sites

Emmanuel Delay 10 Posted June 13 (edited) I'm not sure if I understand your question. What I made: 1 hole left, 1 hole right; 50 units from left or right; vertically aligned in the middle. Radius: 10 Was there something else? ;; @see http://www.cadtutor.net/forum/showthread.php?44768-Entmake-Functions ;; draw a polyline (defun LWPoly (lst cls) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) (cons 70 cls)) (mapcar (function (lambda (p) (cons 10 p))) lst)))) (defun Circle (cen rad) (entmakex (list (cons 0 "CIRCLE") (cons 10 cen) (cons 40 rad)))) ;; vertically in the middle, means: y-value is the average. => p1 + halfOf(p1, p2) ;; => (+ (nth 1 p1) (/ (- (nth 1 p2) (nth 1 p1)) 2)) (defun vmiddle (p1 p2 / ) (+ (nth 1 p1) (/ (- (nth 1 p2) (nth 1 p1)) 2)) ) (defun c:sp ( / p1 p2 y_middle lst my_poly) (setq p1 (getpoint "\nPoint 1:")) (setq p2 (getcorner p1 "\nPoint 2:")) ;; corners of the rectangle: (setq lst (list (list (nth 0 p1) (nth 1 p1) (nth 2 p1)) (list (nth 0 p2) (nth 1 p1) (nth 2 p1)) (list (nth 0 p2) (nth 1 p2) (nth 2 p1)) (list (nth 0 p1) (nth 1 p2) (nth 2 p1)) )) (setq my_poly (LWPoly lst 1)) ;; calculate vertical middle (setq y_middle (vmiddle p1 p2)) ;; circle 1 (left). x-value of p1 + 50 (Circle (list (+ (nth 0 p1) 50) y_middle) 10.0 ;; radius ) ;; circle 2 (right). x-value of p2 - 50 (Circle (list (- (nth 0 p2) 50) y_middle) 10.0 ;; radius ) (princ) ) Edited June 13 by Emmanuel Delay Share this post Link to post Share on other sites

FranknBeans 10 Posted June 14 divide the distance between the centers of the end holes by 200 and fix the result to get the number of circles, then divide the distance by number of circles +1 for the distance between circle centers. Share this post Link to post Share on other sites