+ Reply to Thread
Results 1 to 3 of 3

Thread: Hole Spacing

  1. #1
    Full Member
    Discipline
    Construction
    Using
    AutoCAD 2018
    Join Date
    Nov 2017
    Posts
    40

    Smile Hole Spacing

    Registered forum members do not see this ad.

    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 X but not >than Y Then divide the distance by Z and then write a series of lines to cover all possibilities up to 4000

    regards
    Tony
    Attached Files

  2. #2
    Full Member
    Using
    AutoCAD 2014
    Join Date
    Dec 2010
    Posts
    81

    Default

    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?

    Code:
    ;; @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)
    )
    Last edited by Emmanuel Delay; 13th Jun 2018 at 10:18 pm.

  3. #3
    Full Member
    Using
    AutoCAD 2015
    Join Date
    Jun 2017
    Posts
    27

    Default

    Registered forum members do not see this ad.

    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.

Similar Threads

  1. Text Spacing
    By tennis4you in forum AutoCAD General
    Replies: 4
    Last Post: 10th Jun 2011, 01:42 pm
  2. Spacing LISP
    By Paul H in forum AutoLISP, Visual LISP & DCL
    Replies: 12
    Last Post: 21st Apr 2011, 03:13 pm
  3. Pipe spacing
    By Nick-H- in forum MEP
    Replies: 0
    Last Post: 21st Oct 2010, 04:37 pm
  4. Equal spacing
    By Slinger in forum AutoCAD General
    Replies: 5
    Last Post: 7th Feb 2006, 04:46 pm
  5. Text spacing
    By boofredlay in forum AutoCAD General
    Replies: 3
    Last Post: 14th Oct 2005, 07:41 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts