一个绘制容器中倒流板的程序,请各位高手指出不足之处,多谢!
(setq ag 0);;;原始角(setq WE (+ ag pi));;;西
(setq NO (+ ag (/ pi 2)));;;北
(setq SO (+ WE (/ pi 2)));;;南
(SETQ EA AG);;;东
(SETQ WN (+ AG (* PI 0.75)));;;西北
(SETQ EN (+ AG (* PI 0.25)));;;东北
(SETQ WS (+ AG (* PI 1.25)));;;西南
(SETQ ES (+ AG (* PI 1.75)));;;南
(setq os (getvar "osmode" ))
(defun newos()
(setvar "osmode" 0)
)
(defun oldos()
(setvar "osmode" os)
)
(defun swdraw()
(command "layer" "m" "draw" "" )
)
(defun swcenter()
(command "layer" "m" "center" "" )
)
;;;-----------------------------------------------------
;;;绘制导流板
;;;-----------------------------------------------------
(defun c:dlb()
(SETVAR "errno" 0)
(setvar "cmdecho" 1)
(setq lay (getvar "clayer"))
(setq olderr *error*)
(defun *error* (msg)
(setq errno (getvar "errno"))
;(princ "\n")
;(princ msg)
(reset)
(princ"\n出错!再来")
(c:dlb)
;(setvar *error* olderr)
)
(setq dcl_id (load_dialog "dlb.dcl"))
(if (not (new_dialog "dlb" dcl_id)
)
(exit)
)
;;;初始化
(setq tyft 1 nsz 1 listkswz 0 zxbj 150 listnum 0 nj 1000 bh 10 jj 200)
(action_tile "tyft" "(progn (setq tyft (atoi $Value) dxft 0 pg 0)(mode_tile \"bh\" 0) ) ")
(action_tile "dxft" "(progn (setq dxft (atoi $Value) tyft 0 pg 0)(mode_tile \"bh\" 0) ) ")
(action_tile "pg" "(progn (setq pg (atoi $Value) tyft 0 dxft 0) (mode_tile \"bh\" 1) ) ")
(action_tile "ssz" "(progn (setq ssz (atoi $Value) nsz 0) ) ")
(action_tile "nsz" "(progn (setq nsz (atoi $Value) ssz 0) ) ")
(action_tile "sc" "(progn (setq listnum (atoi $Value)) ) ")
(action_tile "nj" "(progn (setq nj (atoi $Value)) ) ")
(action_tile "bh" "(progn (setq bh (atoi $Value)) ) ")
(action_tile "jj" "(progn (setq jj (atoi $Value)) ) ")
(action_tile "zxbj" "(progn (setq zxbj(atoi $Value)) ) ")
(action_tile "kswz" "(progn (setq listkswz(atoi $value)))")
(action_tile "txt" "(progn (setq txt(atoi $value)))")
(start_image "helpme")
(slide_image 1 1 (dimx_tile "helpme") (dimy_tile "helpme") "orientation")
(end_image)
(action_tile "accept" "(setq flag 1)(done_dialog)")
(action_tile "cancel" "(princ \n退出程序)")
(action_tile "help" "(alert \"\\n1.本程序可以画封头上倒流板的展开图和盘管的俯视图\\n\\n2.本程序画出的螺旋线是通过四点法近似模拟的\\n\\n3.椭圆封头外圆展开尺寸近似为:1.21*(di+2*t)\\n\\n4.碟形封头上外圆展开尺寸近似为:1.12*(di+2*t)\")")
(start_dialog)
(unload_dialog dcl_id)
(if (= flag 1)
(progn
(startdlb)
)
)
)
(defun startdlb()
(setq p0 (getpoint"\n请选择一个中心点:"))
(setq sc (nth listnum (list 1 2 3 4 5 6 8 10 12 15 16 20 25 30 40 50 60 80)))
(setq kswz (nth listkswz (list 0 90 180 270)))
(setq nj (/ nj sc) bh (/ bh sc) jj (/ jj sc) zxbj (/ zxbj sc))
(cond
((= tyft 1)
(setq wj(* 1.21 (+ nj bh)))
)
((= dxft 1)
(setq wj(* 1.12 (+ nj bh)))
)
((= pg 1)
(setq wj nj)
)
)
(setq n 1)
(setq r (+(/ wj 2) (/ jj 8)))
(swcenter)
(newos)
(command "pline" (polar p0 no (/ wj 2)) (polar p0 so (/ wj 2)) ""
"pline" (polar p0 0 (/ wj 2)) (polar p0 pi (/ wj 2)) ""
)
(if (= txt 1)
(progn
(COMMAND "Text" "j" "mc" (polar p0 no (+ 6(/ wj 2))) 5 0 "0%%d" "")
(COMMAND "Text" "j" "mc" (polar p0 0 (+ 6(/ wj 2))) 5 0 "90%%d" "")
(COMMAND "Text" "j" "mc" (polar p0 so (+ 6(/ wj 2))) 5 0 "180%%d" "")
(COMMAND "Text" "j" "mc" (polar p0 pi (+ 7(/ wj 2))) 5 0 "270%%d" "")
)
)
(swdraw)
(cond
((= ssz 1)
(progn
(setq ang (* kswz (/ pi 180)))
(drawssz)
)
)
((= nsz 1)
(progn
(setq ang (* kswz (/ pi 180)))
(drawnsz)
)
)
)
(oldos)
(reset)
(princ "\n命令-->DLB \nBY SWAYWOOD")
)
(defun drawnsz()
(while (> r zxbj)
(progn
(setq p1(polar p0 (- (* (/ pi 4) (- (* 2 n) 1)) ang) (* jj (sqrt 2) 0.125))
r(- r (* 1 0.25 jj))
pt1(polar p1 (- (* n pi 0.5) ang) r)
pt2(polar p1 (- (+ (/ pi 2) (* n pi 0.5)) ang) r)
)
(command "arc" "c" p1 pt1 pt2)
(setq n(+ n 1))
)
)
)
(defun drawssz()
(while (> r zxbj)
(progn
(setq p1(polar p0 (- (* (/ pi 4) (- 5 (* 2 n))) ang) (* jj (sqrt 2) 0.125))
r(- r (* 1 0.25 jj))
pt1(polar p1 (- (* (/ pi 2) (- 2 n)) ang) r)
pt2(polar p1 (- (* (/ pi 2) (- 1 n)) ang) r)
)
(command "arc" "c" p1 pt2 pt1)
(setq n(+ n 1))
)
)
)
(defun reset()
(setvar "clayer" lay)
(setvar "cmdecho" 0)
(setq r nil pt1 nil pt2 nil p0 nil nj nil wj nil bh nil zxbj nil
jj nil sc nil tyft nil dxft nil pg nil ssz nil nsz nil listkswz nil
listnum nil ang nil n nilflag nil txt nil)
(if lay (setq lay nil))
(if os (setvar "osmode" os) (setvar "osmode" 4607))
)
dlb: dialog {
label = "螺旋线模拟" ;
:column{
:boxed_row {
label = "型式";
: radio_button {
key = "tyft";
label = "椭圆封头放样";
value = "1";
}
: radio_button {
key = "dxft";
label = "碟型封头放样";
value = "0";
}
: radio_button {
key = "pg";
label = "盘管俯视图";
value = "0";
}
}
:row{
:boxed_row {
label = "方向";
: radio_button {
key = "ssz";
label = "顺时针";
value = "0";
}
: radio_button {
key = "nsz";
label = "逆时针";
value = "1";
}
}
:boxed_row {
label = "绘图比例";
: popup_list
{ key = "sc";
list ="1:1\n1:2\n1:3\n1:4\n1:5\n1:6\n1:8\n1:10\n1:12\n1:15\n1:16\n1:20\n1:25\n1:30\n1:40\n1:50\n1:60\n1:80";
width = 15;
fixed_height = false;
} }
}
:row{
:boxed_column {
alignment=left;
label = "开始位置";
: popup_list
{ key = "kswz";
list ="0°\n90°\n180°\n270°";
width = 15;
fixed_height = false;
}
: toggle {
key = "txt";
label = " 标出角度文字";
value = "0";
}
: image
{ key = "helpme";
width = 14;
aspect_ratio = 1;
color=dialog_background;
}
}
:boxed_column {
label = "参数";
: edit_box {
edit_width=6;
key = "nj";
label = "封头内径或盘管外圈直径";
value=1000;
}
: edit_box {
edit_width=6;
key = "bh";
label = "壁厚(仅对封头有效)";
value=8;
}
: edit_box {
edit_width=6;
key = "jj";
label = "节距";
value=100;
}
: edit_box {
edit_width=6;
key = "zxbj";
label = "螺旋线半径不小于";
value=150;
}
ok_cancel_help ;
}
}
}
}
回复
"绘制容器中倒流板", 我明白是具体做什么?能加些图示(*)吗? 你要达到什么效果?
单纯这些代码,别人不好理解. 斑竹
下图是运行时的界面和绘制出的螺旋线
我想让各位大侠看一下有哪些地方可以改的更好
另外,我还有几点想请教:
1.能不能实现在选择“型式”中的前两项的时候,参数中的第一个EDIT_BOX的LABEL只显示“封头内径”字样,而选择"判官俯视图“时,则显示”盘管外圈直径“?
2.怎么让我的错误处理做得更好,我对这个不大熟。
3.怎么有效地,更加详细地设置帮助系统(假如我的帮助内容很多的话,如何让程序链接到指定的帮助文件)?
封头尺寸的输入项,如能点击后变成按标准进行选择可能会更好,当然也可以包含自定义项。 锥型封头没有 四楼,五楼说的是,待我有时间时改进,你们也是搞化机的?以后多多交流啊!
如有人能给我解决一下3楼提的问题的话,本人将不胜感激! 楼主程序能不能给我一个Email:pppsheng@163.comQQ:313042743谢谢 <p>程序相当的不错,我时常用到,特别是夹套容器的绘制</p> 问题1的解决方案:
dlb: dialog {
label="螺旋线模拟" ;
:column{
:boxed_row {
label="型式";
: radio_button {key="tyft";label="椭圆封头放样";value="1";}
: radio_button {key="dxft";label="碟型封头放样";value="0";}
: radio_button {key="pg";label="盘管俯视图";value="0";}
}
:row{
:boxed_row {
label="方向";
: radio_button {key="ssz";label="顺时针";value="0";}
: radio_button {key="nsz";label="逆时针";value="1";}
}
:boxed_row {
label="绘图比例";
: popup_list {
key="sc";
list="1:1\n1:2\n1:3\n1:4\n1:5\n1:6\n1:8\n1:10\n1:12\n1:15\n1:16\n1:20\n1:25
\n1:30\n1:40\n1:50\n1:60\n1:80";
width=15;
fixed_height=false;
}
}
}
:row{
:boxed_column {
alignment=left;
label="开始位置";
: popup_list {
key="kswz";
list="0°\n90°\n180°\n270°";width=15;
fixed_height=false;
}
: toggle {key="txt";label=" 标出角度文字";value="0";}
: image {key="helpme";width=14;aspect_ratio=1;color=dialog_background;}
}
:boxed_column {
label="参数";
: row {
: text {key="ftnj";value="封头内径";width=22;}
: edit_box {edit_width=6;key="nj";value=1000;}
}
: edit_box {
edit_width=6;
key="bh";
label="壁厚(仅对封头有效)";
value=8;
}
: edit_box {
edit_width=6;
key="jj";
label="节距";
value=100;
}
: edit_box {
edit_width=6;
key="zxbj";
label="螺旋线半径不小于";
value=150;
}
ok_cancel_help ;
}
}
}
}
(setq ag 0);;;原始角
(setq WE (+ ag pi));;;西
(setq NO (+ ag (/ pi 2)));;;北
(setq SO (+ WE (/ pi 2)));;;南
(SETQ EA AG);;;东
(SETQ WN (+ AG (* PI 0.75)));;;西北
(SETQ EN (+ AG (* PI 0.25)));;;东北
(SETQ WS (+ AG (* PI 1.25)));;;西南
(SETQ ES (+ AG (* PI 1.75)));;;东南
(setq os (getvar "osmode" ))
(defun newos() (setvar "osmode" 0))
(defun oldos() (setvar "osmode" os))
(defun swdraw() (command "layer" "m" "draw" "" ))
(defun swcenter() (command "layer" "m" "center" "" ))
;;;-----------------------------------------------------
;;;绘制导流板
;;;-----------------------------------------------------
(defun c:dlb()
(SETVAR "errno" 0)
(setvar "cmdecho" 1)
(setq lay (getvar "clayer"))
(setq olderr *error*)
(defun *error* (msg)
(setq errno (getvar "errno"))
;(princ "\n")
;(princ msg)
(reset)
(princ"\n出错!再来")
(c:dlb)
;(setvar *error* olderr)
)
(setq dcl_id (load_dialog "dlb.dcl"))
(if (not (new_dialog "dlb" dcl_id)) (exit))
;;;初始化
(start_image "helpme")
(slide_image 1 1 (dimx_tile "helpme") (dimy_tile "helpme") "orientation")
(end_image)
(setq tyft 1 nsz 1 listkswz 0 zxbj 150 listnum 0 nj 1000 bh 10 jj 200)
(action_tile "tyft" "(setq tyft (atoi $Value) dxft 0 pg 0)(set_tile \"ftnj\" \"
封头内径\")(mode_tile \"bh\" 0)")
(action_tile "dxft" "(setq dxft (atoi $Value) tyft 0 pg 0)(set_tile \"ftnj\" \"
封头内径\")(mode_tile \"bh\" 0)")
(action_tile "pg" "(setq pg (atoi $Value) tyft 0 dxft 0)(set_tile \"ftnj\" \"盘
管外圈直径\")(mode_tile \"bh\" 1)")
(action_tile "ssz" "(setq ssz (atoi $Value) nsz 0)")
(action_tile "nsz" "(setq nsz (atoi $Value) ssz 0)")
(action_tile "sc" "(setq listnum (atoi $Value))")
(action_tile "nj" "(setq nj (atoi $Value))")
(action_tile "bh" "(setq bh (atoi $Value))")
(action_tile "jj" "(setq jj (atoi $Value))")
(action_tile "zxbj" "(setq zxbj(atoi $Value))")
(action_tile "kswz" "(setq listkswz(atoi $value))")
(action_tile "txt" "(setq txt(atoi $value))")
(action_tile "accept" "(setq flag 1)(done_dialog)")
(action_tile "cancel" "(princ \n退出程序)")
(action_tile "help" "(alert \"\\n1.本程序可以画封头上倒流板的展开图和盘管的俯视
图\\n\\n2.本程序画出的螺旋线是通过四点法近似模拟的\\n\\n3.椭圆封头外圆展开尺寸近
似为:1.21*(di+2*t)\\n\\n4.碟形封头上外圆展开尺寸近似为:1.12*(di+2*t)\")")
(start_dialog)
(unload_dialog dcl_id)
(if (= flag 1) (startdlb))
(princ)
)
(defun startdlb()
(setq p0 (getpoint"\n请选择一个中心点:"))
(setq sc (nth listnum (list 1 2 3 4 5 6 8 10 12 15 16 20 25 30 40 50 60 80)))
(setq kswz (nth listkswz (list 0 90 180 270)))
(setq nj (/ nj sc) bh (/ bh sc) jj (/ jj sc) zxbj (/ zxbj sc))
(cond
((= tyft 1) (setq wj(* 1.21 (+ nj bh))))
((= dxft 1) (setq wj(* 1.12 (+ nj bh))))
((= pg 1) (setq wj nj))
)
(setq n 1)
(setq r (+(/ wj 2) (/ jj 8)))
(swcenter)
(newos)
(command "line" (polar p0 no (/ wj 2)) (polar p0 so (/ wj 2)) ""
"line" (polar p0 0 (/ wj 2)) (polar p0 pi (/ wj 2)) "")
(if (= txt 1) (progn
(COMMAND "Text" "j" "mc" (polar p0 no (+ 6(/ wj 2))) 5 0 "0%%d" "")
(COMMAND "Text" "j" "mc" (polar p0 0 (+ 6(/ wj 2))) 5 0 "90%%d" "")
(COMMAND "Text" "j" "mc" (polar p0 so (+ 6(/ wj 2))) 5 0 "180%%d" "")
(COMMAND "Text" "j" "mc" (polar p0 pi (+ 7(/ wj 2))) 5 0 "270%%d" "")
))
(swdraw)
(cond
((= ssz 1)
(setq ang (* kswz (/ pi 180)))
(drawssz)
)
((= nsz 1)
(setq ang (* kswz (/ pi 180)))
(drawnsz)
)
)
(oldos)
(reset)
(princ "\n命令-->DLB \nBY SWAYWOOD")
)
(defun drawnsz ()
(while (> r zxbj)
(setq p1 (polar p0 (- (* (/ pi 4) (- (* 2 n) 1)) ang) (* jj (sqrt 2) 0.125))
r (- r (* 1 0.25 jj))
pt1 (polar p1 (- (* n pi 0.5) ang) r)
pt2 (polar p1 (- (+ (/ pi 2) (* n pi 0.5)) ang) r))
(command "arc" "c" p1 pt1 pt2)
(setq n(+ n 1))
)
)
(defun drawssz()
(while (> r zxbj)
(setq p1 (polar p0 (- (* (/ pi 4) (- 5 (* 2 n))) ang) (* jj (sqrt 2) 0.125))
r (- r (* 1 0.25 jj))
pt1 (polar p1 (- (* (/ pi 2) (- 2 n)) ang) r)
pt2 (polar p1 (- (* (/ pi 2) (- 1 n)) ang) r))
(command "arc" "c" p1 pt2 pt1)
(setq n(+ n 1))
)
)
(defun reset()
(setvar "clayer" lay)
(setvar "cmdecho" 0)
(setq r nil pt1 nil pt2 nil p0 nil nj nil wj nil bh nil zxbj nil
jj nil sc nil tyft nil dxft nil pg nil ssz nil nsz nil listkswz nil
listnum nil ang nil n nilflag nil txt nil)
(if lay (setq lay nil))
(if os (setvar "osmode" os) (setvar "osmode" 4607))
)
楼上的对话框程序第22行“ <font color="blue">list</font>=<font color="#880000">"1:1\n1:2\n1:3\n1:4\n1:5\n1:6\n1:8\n1:10\n1:12\n1:15\n1:16\n1:20\n1:25”在1:1前少了n,在加载对话框时出现错误,加了n后就能正常加载了。</font>
页:
[1]
2