TunzaGibbo 发表于 2022-7-5 15:10:04

孔间距

大家好
 
我正在尝试将沿矩形放置孔的过程自动化。
随附的图纸是我用Lisp所能得到的。
我已经在lisp文件中建立了4个角,并且可以在任意一端放置一个孔。
我的问题是,1900的测量值仅用于本例,可以是4000。我实际上不知道这个测量是什么。我所知道的是,需要在每一端50mm处开一个孔,然后在这两个孔之间等距开一个孔,间距不超过200mm。
你能给我一个关于公式如何工作的提示吗。
可能是这样的
如果两个孔之间的距离大于Y,则将该距离除以Z,然后写一系列行,以涵盖所有可能的情况,最大可达4000
 
当做
托尼
孔间距。pdf

Emmanuel Delay 发表于 2022-7-5 16:01:15

我不确定我是否理解你的问题。
我做的:左一洞,右一洞;左或右各50个单元;在中间垂直对齐。
半径:10
 
还有别的事吗?
 

;; @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)
)

FranknBeans 发表于 2022-7-5 16:11:40

将端孔中心之间的距离除以200并固定结果以获得圆数,然后将距离除以圆数+1以获得圆心之间的距离。
页: [1]
查看完整版本: 孔间距