明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4921|回复: 7

[原创]钣金展开

  [复制链接]
发表于 2009-5-29 13:02:00 | 显示全部楼层 |阅读模式

;;;_______________________________________________________
;;; 钣金件展开     langjs 2009.5.5
;;; (本程序仅适用于钣金90度折弯展开计算)
;;;_______________________________________________________

(defun c:ZK( / a ang b cen cm ea ety i k l liangx lst lst2 mm n na name olderr os p1 p2  r r&cen r+ ro sa ss1 sst tl tt uu )
 (setvar "cmdecho" 0)
 (setvar "nomutt" 0)
   (defun error (x) (error_end))
   (defun error_end ()
      (liangxian sst  4 )
      (if cm (setvar "cmdecho" cm))
      (if os (setvar "osmode" os))
      (setq *error* olderr)
   )
   (setq olderr *error* *error* error)
 (prompt "\n选择封闭区域:" )
 (setvar "nomutt" 1)
 (setq sst (ssget '((0 . "line,arc"))))
 (setq liangx   1)
 (setvar "nomutt" 0)
 (setq n (sslength sst))
 (liangxian sst 3 )
 (setq I 0)
 (setq TL 0)
 (setq l 0)
 (setq ss1 (ssadd)  uu '() )
 (while (< I n)
   (setq tt (ssname sst I))
   (setq ety (entget tt))
   (setq name (cdr (assoc 0 ety)))
   (setq I (+ 1 I))
   (cond ((= name "LINE")
       (progn
       (setq L  (distance (cdr (assoc 10 ety)) (cdr (assoc 11 ety))))
       (setq TL (+ TL L))
       (setq  uu  (cons  L  uu)  )
       (setq uu (vl-sort uu '(lambda (a b) (<  a  b))))
       )
       )
       ((= name "ARC")     (setq  ss1  (ssadd tt ss1))  )
    )
  )
(setq t (car uu))
(setq t (sswr t 2 ))
(setq TL(- ( / TL 2  ) t))
(cond (( = t 0.5) (princ))
       (( = t 0.8) (princ))
       (( = t 1) (princ))
       (( = t 1.2) (princ))
       (( = t 1.5) (princ))
       (( = t 2) (princ))
       (( = t 2.5) (princ))
       (( = t 3) (princ))
       (( = t 4) (princ))
       (( = t 5) (princ))
       (( = t 6) (princ))
       (( = t 8) (princ))
       (( = t 10) (princ))
       (t  (progn (alert (strcat "\n错误!\n\n当前计算板厚 t=" (rtos t)"mm。\n\n程序仅支持如下板厚系列:\n
0.5、0.8、1、1.2、1.5、2、\n
2.5、3、4、5、6、8、10 mm")) (exit)))
 )
 (if (= (sslength ss1) 0 )(progn (alert "错误!\n\n程序仅支持圆弧过渡折弯") (exit) ) )
  (setq r+ 0)
  (setq k 0)
  (repeat (sslength ss1)
    (setq na (ssname ss1 k))
    (setq k (1+ k))
    (setq lst (entget na))
    (setq cen (assoc 10 lst))
    (setq r (cdr (assoc 40 lst)))
    (setq sa (cdr (assoc 50 lst)))
    (setq ea (cdr (assoc 51 lst)))
    (setq ang (abs (- ea sa)))
    (if   ( and  (/= 90  ( FIX(+ ( * (/ ang pi )180 ) 0.5) ) ) 
                 (/= 270  ( FIX(+ ( * (/ ang pi )180 ) 0.5) ) )
          )
          (progn (alert "错误!\n\n程序仅支持90度折弯") (exit) )
    )    
    (setq lst2 (cons (list r cen) lst2))
   )
  (setq lst2 (vl-sort lst2 '(lambda (a b) (< (car a) (car b)))))


  (while (setq r&cen (car lst2))
    (setq p1 (mapcar '+ (cadr r&cen) (list 0 (+ (car r&cen) r+) 0 0)))
    (setq p2 (mapcar '- (cadr r&cen) (list -1 (+ (car r&cen) r+) 0 0)))
    (setq
      lst2 (vl-remove-if
      '(lambda (a)
  (EQUAL (cadr a) (cadr r&cen))
       )
      (cdr lst2)
    )
    )
  (setq p1 (cdr p1 ))
  (setq p2 (cdr p2 ))
  (setq ro ( / (distance p1 p2) 2))
  (progn
       (if (and (= t 0.5) (= ro 0.5)) (setq L  1.12))
       (if (and (= t 0.5) (= ro 0.8)) (setq L  1.6))
       (if (and (= t 0.5) (= ro 1)) (setq L    1.93))
       (if (and (= t 0.5) (= ro 1.5)) (setq L  2.72))
       (if (and (= t 0.5) (= ro 2)) (setq L    3.52))
       (if (and (= t 0.5) (= ro 2.5)) (setq L  4.3))
       (if (and (= t 0.5) (= ro 3)) (setq L    5.1))
       (if (and (= t 0.5) (= ro 4)) (setq L    6.66))
       (if (and (= t 0.5) (= ro 5)) (setq L    8.25))
       (if (and (= t 0.5) (= ro 6)) (setq L    9.8))
       (if (and (= t 0.5) (= ro 8)) (setq L    13))
       (if (and (= t 0.5) (= ro 10)) (setq L   16.1))
       (if (and (= t 0.5) (= ro 12)) (setq L   19.24))
       (if (and (= t 0.5) (= ro 13)) (setq L   20.81))
       (if (and (= t 0.5) (= ro 15)) (setq L   23.95))

       (if (and (= t 0.8) (= ro 0.5)) (setq L  1.28))
       (if (and (= t 0.8) (= ro 0.8)) (setq L  1.78))
       (if (and (= t 0.8) (= ro 1)) (setq L    2.11))
       (if (and (= t 0.8) (= ro 1.5)) (setq L  2.93))
       (if (and (= t 0.8) (= ro 2)) (setq L    3.7))
       (if (and (= t 0.8) (= ro 2.5)) (setq L  4.5))
       (if (and (= t 0.8) (= ro 3)) (setq L    5.3))
       (if (and (= t 0.8) (= ro 4)) (setq L    6.88))
       (if (and (= t 0.8) (= ro 5)) (setq L    8.43))
       (if (and (= t 0.8) (= ro 6)) (setq L    10.04))
       (if (and (= t 0.8) (= ro 8)) (setq L    13.2))
       (if (and (= t 0.8) (= ro 10)) (setq L   16.34))
       (if (and (= t 0.8) (= ro 12)) (setq L   19.48))
       (if (and (= t 0.8) (= ro 13)) (setq L   21.05))
       (if (and (= t 0.8) (= ro 15)) (setq L   24.19))

       (if (and (= t 1) (= ro 0.5)) (setq L  1.38))
       (if (and (= t 1) (= ro 0.8)) (setq L  1.9))
       (if (and (= t 1) (= ro 1)) (setq L    2.23))
       (if (and (= t 1) (= ro 1.5)) (setq L  3.05))
       (if (and (= t 1) (= ro 2)) (setq L    3.86))
       (if (and (= t 1) (= ro 2.5)) (setq L  4.65))
       (if (and (= t 1) (= ro 3)) (setq L    5.43))
       (if (and (= t 1) (= ro 4)) (setq L    7.04))
       (if (and (= t 1) (= ro 5)) (setq L    8.62))
       (if (and (= t 1) (= ro 6)) (setq L    10.18))
       (if (and (= t 1) (= ro 8)) (setq L    13.34))
       (if (and (= t 1) (= ro 10)) (setq L   16.5))
       (if (and (= t 1) (= ro 12)) (setq L   19.64))
       (if (and (= t 1) (= ro 13)) (setq L   21.21))
       (if (and (= t 1) (= ro 15)) (setq L   24.35))

       (if (and (= t 1.2) (= ro 0.5)) (setq L  1.48))
       (if (and (= t 1.2) (= ro 0.8)) (setq L  2))
       (if (and (= t 1.2) (= ro 1)) (setq L    2.35))
       (if (and (= t 1.2) (= ro 1.5)) (setq L  3.15))
       (if (and (= t 1.2) (= ro 2)) (setq L    3.99))
       (if (and (= t 1.2) (= ro 2.5)) (setq L  4.77))
       (if (and (= t 1.2) (= ro 3)) (setq L    5.55))
       (if (and (= t 1.2) (= ro 4)) (setq L    7.18))
       (if (and (= t 1.2) (= ro 5)) (setq L    8.75))
       (if (and (= t 1.2) (= ro 6)) (setq L    10.33))
       (if (and (= t 1.2) (= ro 8)) (setq L    13.48))
       (if (and (= t 1.2) (= ro 10)) (setq L   16.62))
       (if (and (= t 1.2) (= ro 12)) (setq L   19.79))
       (if (and (= t 1.2) (= ro 13)) (setq L   21.36))
       (if (and (= t 1.2) (= ro 15)) (setq L   24.5))

       (if (and (= t 1.5) (= ro 0.5)) (setq L  1.63))
       (if (and (= t 1.5) (= ro 0.8)) (setq L  2.16))
       (if (and (= t 1.5) (= ro 1)) (setq L    2.5))
       (if (and (= t 1.5) (= ro 1.5)) (setq L  3.35))
       (if (and (= t 1.5) (= ro 2)) (setq L    4.15))
       (if (and (= t 1.5) (= ro 2.5)) (setq L  4.98))
       (if (and (= t 1.5) (= ro 3)) (setq L    5.79))
       (if (and (= t 1.5) (= ro 4)) (setq L    7.38))
       (if (and (= t 1.5) (= ro 5)) (setq L    8.98))
       (if (and (= t 1.5) (= ro 6)) (setq L    10.53))
       (if (and (= t 1.5) (= ro 8)) (setq L    13.7))
       (if (and (= t 1.5) (= ro 10)) (setq L   16.88))
       (if (and (= t 1.5) (= ro 12)) (setq L   20.03))
       (if (and (= t 1.5) (= ro 13)) (setq L   21.6))
       (if (and (= t 1.5) (= ro 15)) (setq L   24.74))

       (if (and (= t 2) (= ro 0.5)) (setq L  1.88))
       (if (and (= t 2) (= ro 0.8)) (setq L  2.41))
       (if (and (= t 2) (= ro 1)) (setq L    2.76))
       (if (and (= t 2) (= ro 1.5)) (setq L  3.63))
       (if (and (= t 2) (= ro 2)) (setq L    4.46))
       (if (and (= t 2) (= ro 2.5)) (setq L  5.28))
       (if (and (= t 2) (= ro 3)) (setq L    6.09))
       (if (and (= t 2) (= ro 4)) (setq L    7.73))
       (if (and (= t 2) (= ro 5)) (setq L    9.32))
       (if (and (= t 2) (= ro 6)) (setq L    10.9))
       (if (and (= t 2) (= ro 8)) (setq L    14.07))
       (if (and (= t 2) (= ro 10)) (setq L   17.22))
       (if (and (= t 2) (= ro 12)) (setq L   20.42))
       (if (and (= t 2) (= ro 13)) (setq L   21.99))
       (if (and (= t 2) (= ro 15)) (setq L   25.13))

       (if (and (= t 2.5) (= ro 0.5)) (setq L  2.13))
       (if (and (= t 2.5) (= ro 0.8)) (setq L  2.67))
       (if (and (= t 2.5) (= ro 1)) (setq L    3.01))
       (if (and (= t 2.5) (= ro 1.5)) (setq L  3.88))
       (if (and (= t 2.5) (= ro 2)) (setq L    4.75))
       (if (and (= t 2.5) (= ro 2.5)) (setq L  5.57))
       (if (and (= t 2.5) (= ro 3)) (setq L    6.39))
       (if (and (= t 2.5) (= ro 4)) (setq L    8.05))
       (if (and (= t 2.5) (= ro 5)) (setq L    9.65))
       (if (and (= t 2.5) (= ro 6)) (setq L    11.25))
       (if (and (= t 2.5) (= ro 8)) (setq L    14.4))
       (if (and (= t 2.5) (= ro 10)) (setq L   17.55))
       (if (and (= t 2.5) (= ro 12)) (setq L   20.81))
       (if (and (= t 2.5) (= ro 13)) (setq L   22.38))
       (if (and (= t 2.5) (= ro 15)) (setq L   25.53))

       (if (and (= t 3) (= ro 0.5)) (setq L  2.36))
       (if (and (= t 3) (= ro 0.8)) (setq L  2.29))
       (if (and (= t 3) (= ro 1)) (setq L    3.26))
       (if (and (= t 3) (= ro 1.5)) (setq L  4.13))
       (if (and (= t 3) (= ro 2)) (setq L    5))
       (if (and (= t 3) (= ro 2.5)) (setq L  5.81))
       (if (and (= t 3) (= ro 3)) (setq L    6.69))
       (if (and (= t 3) (= ro 4)) (setq L    8.35))
       (if (and (= t 3) (= ro 5)) (setq L    9.98))
       (if (and (= t 3) (= ro 6)) (setq L    11.6))
       (if (and (= t 3) (= ro 8)) (setq L    14.75))
       (if (and (= t 3) (= ro 10)) (setq L   17.8))
       (if (and (= t 3) (= ro 12)) (setq L   21.09))
       (if (and (= t 3) (= ro 13)) (setq L   22.78))
       (if (and (= t 3) (= ro 15)) (setq L   25.92))

       (if (and (= t 4) (= ro 0.5)) (setq L  2.83))
       (if (and (= t 4) (= ro 0.8)) (setq L  3.39))
       (if (and (= t 4) (= ro 1)) (setq L    3.77))
       (if (and (= t 4) (= ro 1.5)) (setq L  4.64))
       (if (and (= t 4) (= ro 2)) (setq L    5.51))
       (if (and (= t 4) (= ro 2.5)) (setq L  6.39))
       (if (and (= t 4) (= ro 3)) (setq L    7.25))
       (if (and (= t 4) (= ro 4)) (setq L    8.92))
       (if (and (= t 4) (= ro 5)) (setq L    10.57))
       (if (and (= t 4) (= ro 6)) (setq L    12.22))
       (if (and (= t 4) (= ro 8)) (setq L    16.54))
       (if (and (= t 4) (= ro 10)) (setq L   18.64))
       (if (and (= t 4) (= ro 12)) (setq L   21.8))
       (if (and (= t 4) (= ro 13)) (setq L   23.37))
       (if (and (= t 4) (= ro 15)) (setq L   26.55))

       (if (and (= t 5) (= ro 0.5)) (setq L  3.3))
       (if (and (= t 5) (= ro 0.8)) (setq L  3.86))
       (if (and (= t 5) (= ro 1)) (setq L    4.24))
       (if (and (= t 5) (= ro 1.5)) (setq L  5.18))
       (if (and (= t 5) (= ro 2)) (setq L    6.07))
       (if (and (= t 5) (= ro 2.5)) (setq L  6.91))
       (if (and (= t 5) (= ro 3)) (setq L    7.77))
       (if (and (= t 5) (= ro 4)) (setq L    9.55))
       (if (and (= t 5) (= ro 5)) (setq L    11.16))
       (if (and (= t 5) (= ro 6)) (setq L    12.8))
       (if (and (= t 5) (= ro 8)) (setq L    16.1))
       (if (and (= t 5) (= ro 10)) (setq L   19.3))
       (if (and (= t 5) (= ro 12)) (setq L   22.52))
       (if (and (= t 5) (= ro 13)) (setq L   24.06))
       (if (and (= t 5) (= ro 15)) (setq L   27.25))

       (if (and (= t 6) (= ro 0.5)) (progn (alert "折弯半径太小无法计算")(exit)     ))
       (if (and (= t 6) (= ro 0.8)) (progn (alert "折弯半径太小无法计算")(exit)     ))
       (if (and (= t 6) (= ro 1))   (progn (alert "折弯半径太小无法计算")(exit)     ))
       (if (and (= t 6) (= ro 1.5)) (setq L  5.65))
       (if (and (= t 6) (= ro 2)) (setq L    6.54))
       (if (and (= t 6) (= ro 2.5)) (setq L  7.41))
       (if (and (= t 6) (= ro 3)) (setq L    8.29))
       (if (and (= t 6) (= ro 4)) (setq L    9.99))
       (if (and (= t 6) (= ro 5)) (setq L    11.67))
       (if (and (= t 6) (= ro 6)) (setq L    13.38))
       (if (and (= t 6) (= ro 8)) (setq L    16.59))
       (if (and (= t 6) (= ro 10)) (setq L   19.89))
       (if (and (= t 6) (= ro 12)) (setq L   23.14))
       (if (and (= t 6) (= ro 13)) (setq L   24.72))
       (if (and (= t 6) (= ro 15)) (setq L   27.93))

       (if (and (= t 8) (= ro 0.5)) (progn (alert "折弯半径太小无法计算")(exit)     ))
       (if (and (= t 8) (= ro 0.8)) (progn (alert "折弯半径太小无法计算")(exit)     ))
       (if (and (= t 8) (= ro 1)) (progn (alert "折弯半径太小无法计算")(exit)     ))
       (if (and (= t 8) (= ro 1.5)) (progn (alert "折弯半径太小无法计算")(exit)     ))
       (if (and (= t 8) (= ro 2)) (setq L    7.54))
       (if (and (= t 8) (= ro 2.5)) (setq L  8.45))
       (if (and (= t 8) (= ro 3)) (setq L    9.3))
       (if (and (= t 8) (= ro 4)) (setq L    11.06))
       (if (and (= t 8) (= ro 5)) (setq L    12.75))
       (if (and (= t 8) (= ro 6)) (setq L    14.45))
       (if (and (= t 8) (= ro 8)) (setq L    17.84))
       (if (and (= t 8) (= ro 10)) (setq L   21.08))
       (if (and (= t 8) (= ro 12)) (setq L   24.35))
       (if (and (= t 8) (= ro 13)) (setq L   26.01))
       (if (and (= t 8) (= ro 15)) (setq L   29.22))

       (if (and (= t 10) (= ro 0.5)) (progn (alert "折弯半径太小无法计算")(exit)     ))
       (if (and (= t 10) (= ro 0.8)) (progn (alert "折弯半径太小无法计算")(exit)     ))
       (if (and (= t 10) (= ro 1)) (progn (alert "折弯半径太小无法计算")(exit)     ))
       (if (and (= t 10) (= ro 1.5)) (progn (alert "折弯半径太小无法计算")(exit)     ))
       (if (and (= t 10) (= ro 2)) (progn (alert "折弯半径太小无法计算")(exit)     ))
       (if (and (= t 10) (= ro 2.5)) (setq L  9.43))
       (if (and (= t 10) (= ro 3)) (setq L    10.37))
       (if (and (= t 10) (= ro 4)) (setq L    11.62))
       (if (and (= t 10) (= ro 5)) (setq L    13.82))
       (if (and (= t 10) (= ro 6)) (setq L    15.55))
       (if (and (= t 10) (= ro 8)) (setq L    18.85))
       (if (and (= t 10) (= ro 10)) (setq L   22.31))
       (if (and (= t 10) (= ro 12)) (setq L   22.5))
       (if (and (= t 10) (= ro 13)) (setq L   27.14))
       (if (and (= t 10) (= ro 15)) (setq L   30.43))
  )
  (setq TL (+ TL L))
 )
  (princ)

(princ"\n板材厚度 t=")
(princ t)
(setq TL (sswr TL 2 ))
(princ"\n展开长度 L=")
(princ TL)
(alert (strcat "\n板材厚度 t = " (rtos t) " mm \n\n展开长度 L = " (rtos TL) " mm " )  )
(error_end)
(liangxian sst 4 )
(princ)
)

;;四舍五入函数,ent:实数,n:小数点保留位数
(defun sswr(ent n / FH)
(if (>= ent 0.0)(setq FH +)(setq FH -))
(setq ent(/(atof(itoa(fix(FH(* ent(expt 10 n))0.5))))(expt 10 n)))
ent
)

(defun liangxian (ss  n / slen I  ent );;控制选择集亮显程序
   (if  (/= liangx 0);;亮显判断条件
        (progn
        (setq slen (sslength ss) I 0 )
        (while (ssname ss I)
           (setq ent (ssname ss I))
           (redraw ent n);亮显
           (setq I (+ 1 I))
        );end while
        );end progn
   );end if
);end defun
;;;_______________________________________________________
 

"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2009-5-29 22:22:00 | 显示全部楼层

不知道怎么用的哦,请指教哦。

发表于 2011-12-14 12:12:42 | 显示全部楼层
有没有弧形展开的程序?

点评

弧形展开我有 但文件太大  发表于 2017-10-10 20:23
发表于 2012-6-30 23:43:23 | 显示全部楼层
請問這個有說明嗎!
发表于 2014-8-20 19:29:25 | 显示全部楼层
有动态图吗好版主
发表于 2023-3-23 15:25:52 | 显示全部楼层
感谢分享,就是展开长度差得很多
发表于 2023-11-2 23:15:17 | 显示全部楼层
L神 请问下如何使用此款插件
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-2-24 07:12 , Processed in 0.196314 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表