AutoLisp Adjustments

AutoLisp Adjustments

chris.schmidtHNQZK
Explorer Explorer
284 Views
3 Replies
Message 1 of 4

AutoLisp Adjustments

chris.schmidtHNQZK
Explorer
Explorer

Hi everyone,

I am trying to come up with a lisp routine that puts rivet holes (circles) in the perimeter of an ACM panel (see attachment). The holes need to be equally spaced with a maximum spacing of 24" o.c. and the first and last hole being 3" off the ends on all sides.

I found a lisp that does almost exactly what I need it to do (see below) except it puts two circles at either end, the first 1" off the ends and the second 1.75" of the ends. I was able to edit the lisp so as to get the correct spacing, layer, diameter, and distance from the edges. I can not figure out how to eliminate one of the circles at the ends and place the first and last hole 3" off the ends.

Can someone please help?

 

Thanks!

 

(defun c:HOLES (/ gc:clockwise-p _aap _c a d d2 e ep f i l r sp)
  ;; RJP » 2023-02-02
  (defun _c (p) (entmakex (list '(0 . "CIRCLE") '(8 . "HOLES") '(40 . 0.06425) (cons 10 p))))
  (defun _aap (e pt / a clpt e pa)
    (if (and (not (vl-catch-all-error-p (vl-catch-all-apply 'vlax-curve-getendparam (list e))))
     (setq clpt (vlax-curve-getclosestpointto e pt))
     (setq pa (vlax-curve-getparamatpoint e clpt))
     (setq a (angle '(0 0 0) (vlax-curve-getfirstderiv e pa)))
)
      a
    )
  )
  ;; Clockwise-p  -  gile
  (defun gc:clockwise-p (p1 p2 p3) (< (sin (- (angle p1 p3) (angle p1 p2))) -1e-14))
  (cond ((and (setq e (car (entsel "\nPick a panel frame: ")))
      (= "LWPOLYLINE" (cdr (assoc 0 (entget e))))
      (setq sp (vlax-curve-getstartparam e))
      (setq ep (vlax-curve-getendparam e))
)
(repeat (fix ep)
   (cond ((> (setq l (- (abs (- (vlax-curve-getdistatparam e sp)
(vlax-curve-getdistatparam e (setq sp (1+ sp)))
     )
)
5.5
     )
     )
     6
  )
  (setq d2 (/ l (setq i (1+ (fix (/ l 24))))))
  (setq d (vlax-curve-getdistatparam e (1- sp)))
  (foreach b '(1.0 1.75)
    ;;----------------
    (setq r (cons (_c (vlax-curve-getpointatdist e (setq d (+ d b)))) r))
  )
  (repeat i (setq r (cons (_c (vlax-curve-getpointatdist e (setq d (+ d d2)))) r)))
  ;;----------------------------------------------------------------------------------
  (setq r (cons (_c (vlax-curve-getpointatdist e (setq d (+ d 1.75)))) r))
)
   )
)
(setq f (if (gc:clockwise-p
       (vlax-curve-getpointatparam e 0)
       (vlax-curve-getpointatparam e 1)
       (vlax-curve-getpointatparam e 2)
     )
   +
   -
)
)
(foreach el r
   (setq a (cdr (assoc 10 (entget el))))
   (entmod (append (entget el) (list (cons 10 (polar a (f (_aap e a) (/ pi 2)) 0.375)))))
)
)
  )
  (princ)
)
0 Likes
285 Views
3 Replies
Replies (3)
Message 2 of 4

Sea-Haven
Mentor
Mentor

For me start again.

 

(defun c:makeholes3 ( / oldsnap wid off dia endoff off2 pt1 pt2 pt3 pt4)
(command "-layer" "M" "VROUT" "C" 4 "VROUT" "M" "CUTOUT" "C" 3 "CUTOUT""M" "HOLES" "C" 5 "HOLES" "")

(setq oldsnap (getvar 'osmode))

(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Enter values " "Length " 5 4 "60" "Width " 5 4 "25" "Offset " 5 4 "1" "Dia " 5 4 "0.06425" "End off " 5 4 "3")))

(setq len (atof (nth 0 ans)) 
  wid  (atof (nth 1 ans))
  off (atof (nth 2 ans))
  dia (atof (nth 3 ans))
  endoff (atof (nth 4 ans))
  off2 (/ off 2.0)
)

(setq pt1 (getpoint "\nPick bottom left point "))
(setq pt2 (mapcar '+ pt1 (list len 0.0 0.0)))
(setq pt3 (mapcar '+ pt1 (list len wid 0.0)))
(setq pt4 (mapcar '+ pt1 (list 0.0 wid 0.0)))

(setvar 'clayer "VROUT")
(command "rectang" pt1 pt3)

(setvar 'clayer "CUTOUT")
(setvar 'osmode 0)
(command "pline" pt4  (mapcar '+ pt4 (list 0.0 off 0.0)) (mapcar '+ pt3 (list 0.0 off 0.0)) pt3 "")
(command "pline" pt1  (mapcar '+ pt1 (list 0.0 (- off) 0.0)) (mapcar '+ pt2 (list 0.0 (- off) 0.0)) pt2 "")
(command "pline" pt1  (mapcar '+ pt1 (list (- off) 0.0  0.0)) (mapcar '+ pt4 (list (- off) 0.0  0.0)) pt4 "")
(command "pline" pt2 (mapcar '+ pt2 (list off 0.0  0.0)) (mapcar '+ pt3 (list off 0.0  0.0)) pt3 "")

(setvar 'clayer "HOLES")
(command "circle" (mapcar '+ pt1 (list endoff (- off2)  0.0)) dia)
(command "circle" (mapcar '+ pt1 (list (- off2)  endoff  0.0)) dia)

(command "circle" (mapcar '+ pt2 (list (- endoff) (- off2)  0.0)) dia)
(command "circle" (mapcar '+ pt2 (list off2  endoff  0.0)) dia)

(command "circle" (mapcar '+ pt3 (list (- endoff) off2  0.0)) dia)
(command "circle" (mapcar '+ pt3 (list off2  (- endoff) 0.0)) dia)

(command "circle" (mapcar '+ pt4 (list endoff off2  0.0)) dia)
(command "circle" (mapcar '+ pt4 (list (- off2)  (- endoff) 0.0)) dia)

(setvar 'osmode oldsnap)

(princ)
)

SeaHaven_0-1692254148042.png

 

 

 Save multi getvals.lsp in a support path or change (Load "multi getvals") to full file path

0 Likes
Message 3 of 4

chris.schmidtHNQZK
Explorer
Explorer

Thank you very much for your help and efforts. However, this lisp does not do what I need it to do. I do not need it to draw the panel(s), just the holes (circles). The panels are already drawn. These panels come in all different shapes and sizes and are not always rectangular or have 90° angles.

What I am looking for is a lisp routine that is similar to the "HOLES" routine (above). I need a routine that places circles 3" off the ends of the CUTOUT line on either end and on all four sides and then places intermediate circles at a spacing of 24" o.c. max. The circles are also offset from the perimeter of the panel by 3/8" as shown in the attachment. 

 

Thanks,

Chris

0 Likes
Message 4 of 4

Sea-Haven
Mentor
Mentor

More explanation would have been good at start say random shape. Anyway the plines are a bit difficult to use so a easier way is remake a temporary pline with some values like edge distance and offset. Just pick a point inside shape and holes are drawn.

Shape like this, will have a think.

 

SeaHaven_0-1692422006412.png

 

 

`

0 Likes