找回密码
 [加入论坛]
查看: 1353|回复: 0

对称布管程序的原码

[复制链接]
2443725 发表于 2004-9-5 15:02 | 显示全部楼层 |阅读模式


<>[Point=15]</P>
<P>[upload=jpg]UploadFile/2004-9/未命名.jpg___200495714153.jpg[/upload]</P>
<P>说明:本程序在sjiang原始程序上做了修改,</P>
<P><FONT color=#ff0000>而且本程序可以自动修整换热管的中心线, 希望高手能将这个程序完善一下,</FONT></P>
<P>;;--------------------------------------------
(defun c:bg ( / bc hrgwj1 hrqnj1 lin_dcl opt p0 p1 p2 p3 plstpipe ri zhxj1)
  (setvar "osmode" 0)
  (gc)
  ;;(setq di (getint "\n请输入换热器内径:"))
  ;;(setq d0 (getreal "\n请输入换热管外径:"))
  ;;(setq st (getreal "\n请输入换热管管间距:"))
  ;;(setq st1 (* st 0.8660254037844))
  ;;(princ st1)
  (setvar "CMDECHO" 0)
  (setq lin_dcl (load_dialog "hrqbg.dcl"))
  (if (not (new_dialog "hrqbg" lin_dcl))
    (exit)
  )
  (action_tile
    "hrqnj"
    "(setq hrqnj (atof (get_tile \"hrqnj\")))"
  )
  (action_tile
    "hrgwj"
    "(setq hrgwj (atof (get_tile \"hrgwj\")))"
  )
  (action_tile
    "zhxj"
    "(setq zhxj (atof (get_tile \"zhxj\")))"
  )
  (mode_tile "hrqnj" 2)
  (mode_tile "hrqnj" 3)
  (setq hrqnj1 (list "300"    "350"    "400" "450"  "500"   "550"
       "600"    "650"    "700" "750"  "800"   "850"
       "900"    "950"    "1000" "1100"  "1200"   "1300"
       "1400"   "1500"   "1600" "1700"  "1800"   "1900"
       "2000"
      )
  )
  (start_list "hrqnj_pup")
  (mapcar 'add_list hrqnj1)
  (end_list)
  (action_tile
    "hrqnj_pup"
    "(setq hrqnj_pup $value)
          (set_tile \"hrqnj\" (nth (read hrqnj_pup) hrqnj1)) (mode_tile \"hrqnj\" 2)"
  )
  (setq hrgwj1 (list "16" "19" "20" "22" "25" "30" "32" "35" "38" "45" "50" "55"
       "57")
  )
  (start_list "hrgwj_pup")
  (mapcar 'add_list hrgwj1)
  (end_list)
  (action_tile
    "hrgwj_pup"
    "(setq hrgwj_pup $value) (bg_zhxj)
          (set_tile \"hrgwj\" (nth (read hrgwj_pup) hrgwj1)) (mode_tile \"hrgwj\" 2)"
  )
  ;;(setq zhxj1 (list "22" "25" "26" "28" "38" "40" "44" "48" "57" "64" "70" "72"))
  ;;(start_list "zhxj_pup")
  ;;(mapcar 'add_list zhxj1)
  ;;(end_list)
  ;;(action_tile "zhxj_pup" "(setq zhxj_pup $value)
  ;;(set_tile \"zhxj\" (nth (read zhxj_pup) zhxj1)) (mode_tile \"zhxj\" 2)")
  (action_tile
    "accept"
    "(if (or (=\"\" (get_tile \"hrqnj\"))
                                   (=\"\" (get_tile \"hrgwj\"))
                                   (=\"\" (get_tile \"zhxj\")))
                               (alert_bg) (done_dialog 1))"
  )
  (action_tile
    "xngx"
    "(alert (strcat \"基本数据中的换热器内径、换热管外径既可以从键盘输入,也可以\"
                                        \"\n\n从下拉列表中选取。从下拉列表中选取换热管外径时会自动给出换\"
                                        \"\n\n热管中心距。中心距也可以根据实际需要改变。\"))"
  )
  (action_tile "cancel" "(done_dialog 0)")
  (if (= (start_dialog) 1)
    (progn
      ;; 此处开始绘图部分
      ;; 三角形布管
      (setq zhxj1 (* zhxj (expt 3.0 0.5) 0.5))
      (setq ri (- (/ hrqnj 2) 10)) ;布管限定圆半径
      (setq p0 (getpoint "\n请指定圆心"))
      (command "circle" p0 ri) ;圆筒内径
      (setq bc (entlast))
      (command "circle" p0 "d" hrqnj) ;布管限定圆</P>
<P>      ;;中心线   
      (command "line"
        (list (- (car p0) ri 20) (cadr p0))
        (list (+ (car p0) ri 20) (cadr p0))
        ""
      )
      (command "line"
        (list (car p0) (- (cadr p0) ri 20))
        (list (car p0) (+ (cadr p0) ri 20))
        ""
      )</P>
<P>      ;; 设置绘制换热管的点,基点为p0
      (setq p1 p0)
      (setq p1 (list (+ (car p0) (/ zhxj 2.0)) (cadr p0)))
      (setq p2 (list (+ (car p1) zhxj) (cadr p1)))
      (setq p3 (list (- (car p1) zhxj) (cadr p1)))
      (setq opt 1)
      (setq plstPipe '()) ;构造换热管中心点的表 plstPipe
      (while (&lt; (+ (distance p2 p0) (/ hrgwj 2)) ri) ;判断是否超过上边界ri
;; 在p1点绘制管
(if (= opt 1)
   (progn
     (command "circle" p1 (/ hrgwj 2))
     (setq plstPipe (append plstPipe (list p1)))
   )
)</P>
<P>;; 从p1-&gt;p2开始向右边布管
(while (&lt; (+ (distance p2 p0) (/ hrgwj 2)) ri)
   (command "circle" p2 (/ hrgwj 2))
   (setq plstPipe (append plstPipe (list p2)))
   (setq p2 (list (+ (car p2) zhxj) (cadr p2)))
)
;; 从p1-&gt;p3开始向左边布管
(while (&lt; (+ (distance p3 p0) (/ hrgwj 2)) ri)
   (command "circle" p3 (/ hrgwj 2))
   (setq plstPipe (append plstPipe (list p3)))
   (setq p3 (list (- (car p3) zhxj) (cadr p3)))
)</P>
<P>;; 将p2,p3向上一排
(setq p2 (list (+ (car p1) (/ zhxj 2.0)) (+ (cadr p1) zhxj1)))
(setq p3 (list (- (car p1) (/ zhxj 2.0)) (+ (cadr p1) zhxj1)))
(setq opt (* opt -1))</P>
<P>(if (= opt 1)
   (progn (setq p1 p3)
   (setq p3 (list (- (car p1) zhxj) (cadr p1)))
   )
   (setq p1 p2)
)</P>
<P>      ) ;end while</P>
<P>      (command "zoom" "all")
      ;;绘制换热管间的中心连接线
      (bg_drawCenterLine plstPipe zhxj)
    )
  )
  ;;end if progn</P>
<P>  (setvar "CMDECHO" 1)
  (setvar "OSMODE" 0)</P>
<P>  (princ)
)</P>
<P>;; 函数: 绘制换热管中心间的连接线       ;
;; 参数: plstVar -- 换热管中心点列表    ;
;;        rPitch  -- 换热管中心距        ;
(defun bg_DrawCenterLine (plstVar rPitch / pcurcen plstcent plstright)
  
  (setq plstCent plstVar)
  (if (not (null plstCent))
    (progn
      (setq pCurCen   (car plstCent)
     plstRight (cdr plstCent)
      )
      (if (not (null plstRight))
(foreach pTmpCen plstRight
   (if (equal (distance pCurCen pTmpCen) rPitch 1e-3)
     (command "_.Line" pTmpCen pCurCen "")
   )
)
      ) ;end if
    )
  )
  (bg_drawCenterLine pLstRight rPitch)
)</P>
<P>
;; 设置管间距
(defun bg_zhxj ()
  (cond ((= (atoi hrgwj_pup) 0) (setq zhxj 22))
((= (atoi hrgwj_pup) 1) (setq zhxj 25))
((= (atoi hrgwj_pup) 2) (setq zhxj 26))
((= (atoi hrgwj_pup) 3) (setq zhxj 28))
((= (atoi hrgwj_pup) 4) (setq zhxj 32))
((= (atoi hrgwj_pup) 5) (setq zhxj 38))
((= (atoi hrgwj_pup) 6) (setq zhxj 40))
((= (atoi hrgwj_pup) 7) (setq zhxj 44))
((= (atoi hrgwj_pup) 8) (setq zhxj 48))
((= (atoi hrgwj_pup) 9) (setq zhxj 57))
((= (atoi hrgwj_pup) 10) (setq zhxj 64))
((= (atoi hrgwj_pup) 11) (setq zhxj 70))
((= (atoi hrgwj_pup) 12) (setq zhxj 72))
  )
  (set_tile "zhxj" (rtos zhxj 2))
)</P>
<P>
;; 出错警告处理
(defun alert_bg ()
  (cond ((= "" (get_tile "hrqnj"))
  (alert "没有选取或给定换热器内径!请选取或给定换热器内径!")
)
((= "" (get_tile "hrgwj"))
  (alert "没有选取或给定换热管外径!请选取或给定换热管外径!")
)
((= "" (get_tile "zhxj"))
  (alert
    "没有选取或给定换热管中心距!请选取或给定换热管中心距!"
  )
)
  )
)</P>
<P>;; 显示错误信息
(defun *error* (msg)
  (setvar "OSMODE" 0)
)
</P>
<P>[/Point]</P>
[此贴子已经被作者于2004-9-5 7:03:57编辑过]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?[加入论坛]

×
您需要登录后才可以回帖 登录 | [加入论坛]

本版积分规则

手机版|化工技术网- 赠人玫瑰 手有余香 ( 苏ICP备14035884号 )

GMT+8, 2026-12-1 16:18

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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