明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1258|回复: 3

老是看不出来哪里有错,高手们帮帮忙吧~~~~~~

[复制链接]
发表于 2005-6-11 16:33:00 | 显示全部楼层 |阅读模式
这是我从别处抄来的程序,自己水平为零,照着函数表边看边学,越看越恍然大悟,结果看完了一运行竟然不对,只出现对话框,幻灯片还不显示,还说我函数被取消,欺负人……可能思路受限制,老是看不出来哪里有错,高手们帮帮忙吧~~~~~~谢谢啦 先是对话框文件 flpdlg:dialog{
label="法兰盘参数化绘图";
:column{
:boxed_column{
:image{
key="flp";
width=30;
aspect_ratio=1;
color=9;
}
}
:row{
:boxed_column{
label="请输入插入点:";
:edit_box{
label="坐标 x:";
key="x";
edit_width=7;
}
:edit_box{
label="坐标 y:";
key="y";
edit_width=7;
}
} :boxed_column{
label="请输入法兰盘参数:";
:edit_box{
label="外径 R1:";
key="R1";
edit_width=7;
}
:edit_box{
label="内径R2:";
key="R2";
edit_width=7;
}
:edit_box{
label="法兰孔半径R3:";
key="R3";
edit_width=7;
}
:edit_box{
label="法兰孔个数n:";
key="n";
edit_width=7;
}
}
} }
ok_cancel;
} 然后是.lsp文件 ;定义函数名为“falanpan”
(defun falanpan()
;将对话框文件调入内存
(New_Dialog "flpdlg" (load_dialog "falanpan"))
;将图像控件的幻灯片调入
(Start_Image "flp")
(Slide_Image 0 0 (Dimx_Tile "flp") (Dimy_Tile "flp") "flp")
(End_Image)
;获取编辑框控件的输入值,为字符串形式
(action_tile "R1" "(setq s1 $value)")
(action_tile "R2" "(setq s2 $value)")
(action_tile "R3" "(setq s3 $value)")
(action_tile "n" "(setq n1 $value)")
(action_tile "x" "(setq x1 $value)")
(action_tile "y" "(setq y1 $value)")
;开始对话框,将控制权交给用户
(Start_Dialog)
;判断返回码,进行下一步工作
(if (= 1 (Start_Dialog))
;将获得的输入转换成整数或实数
(progn (setq r3 (atof s1)
r1 (atof s2)
r (atof s3)
n (atoi n1)
x (atof x1)
y (atof y1)
)
(setq pt(list x y 0.0))
)
)
;计算必要参数
(setq r2 (/(+ r1 r3)2))
(setq pt1 (polar pt (/ pi 2.0)(+ r3 3))
pt2 (polar pt (-(/ pi 2.0))(+ r3 3))
pt3 (polar pt pi(+ r3 3))
pt4 (polar pt 0.0 (+ r3 3))
)
;绘图指令
(command "ltscale" "10")
(command "layer" "m" "0" "1" "continuous" "0" "c" "green" "0" "")
(command "circle" pt r1)
(command "circle" pt r3)
(command "circle" (polar pt 0 r2) r)
(command "array" "1" "" "p" pt n 360 "n")
(command "ltscale" "30")
(command "layer" "m" "1" "1" "center" "1" "c" "red" "1" "")
(command "circle" pt r2)
(command "line" pt1 pt2 "")
(command "line" pt3 pt4 "")
(command "redraw")
(setq area (* pi (-(* r3 r3)(* r1 r1)(* n r r))))
)
 楼主| 发表于 2005-6-11 16:47:00 | 显示全部楼层
没人理呀没人理,555555555
发表于 2005-6-13 13:38:00 | 显示全部楼层
  1. ;读入参数
  2. (defun readdata ()
  3.   (setq r3 (atof (get_tile "R1"))
  4.              r1 (atof (get_tile "R2"))
  5.              r (atof (get_tile "R3"))
  6.              n (atof (get_tile "n"))
  7.              x (atof (get_tile "x"))
  8.              y (atof (get_tile "y"))
  9.   )
  10. )
  11. ;主程序
  12. (defun c:falanpan()
  13. (if (> (setq dcl_id (load_dialog "falanpan")) 0) (progn
  14.   (if (new_dialog "flpdlg" dcl_id) (progn
  15.    (Start_Image "flp")
  16.    (Slide_Image 0 0 (Dimx_Tile "flp") (Dimy_Tile "flp") "flp")
  17.    (End_Image)
  18.    (action_tile "accept" "(readdata) (done_dialog 1)")
  19.    (action_tile "cancel" "(done_dialog 0)")
  20.    (setq re (Start_Dialog))
  21.   ))
  22.    (unload_dialog dcl_id)
  23. ))
  24. (if (= re 1 ) (progn
  25.   (setq pt(list x y 0.0))
  26.   (setq r2 (/ (+ r1 r3) 2))
  27.   (setq pt1 (polar pt (/ pi 2.0)(+ r3 3))
  28.              pt2 (polar pt (-(/ pi 2.0))(+ r3 3))
  29.              pt3 (polar pt pi(+ r3 3))
  30.              pt4 (polar pt 0.0 (+ r3 3))
  31.   )
  32.   (command "ltscale" "10")
  33.   (command "layer" "m" "0" "1" "continuous" "0" "c" "green" "0" "")
  34.   (command "circle" pt r1)
  35.   (command "circle" pt r3)
  36.   (command "circle" (polar pt 0 r2) r)
  37.   (command "array" "1" "" "p" pt n 360 "n")
  38.   (command "ltscale" "30")
  39.   (command "layer" "m" "1" "1" "center" "1" "c" "red" "1" "")
  40.   (command "circle" pt r2)
  41.   (command "line" pt1 pt2 "")
  42.   (command "line" pt3 pt4 "")
  43.   (command "redraw")
  44.   (setq area (* pi (-(* r3 r3)(* r1 r1)(* n r r))))
  45. ))
  46. (princ)
  47. )
发表于 2005-6-13 22:59:00 | 显示全部楼层
调试过的程序
  1. ;读入参数
  2. (defun readdata ()
  3.   (setq r3 (atof (get_tile "R1"))
  4.              r1 (atof (get_tile "R2"))
  5.              r (atof (get_tile "R3"))
  6.              n (atoi (get_tile "n"))
  7.              x (atof (get_tile "x"))
  8.              y (atof (get_tile "y"))
  9.   )
  10. )
  11. ;主程序
  12. (defun c:falanpan ()
  13. (if (> (setq dcl_id (load_dialog "falanpan")) 0) (progn
  14.   (if (new_dialog "flpdlg" dcl_id "") (progn
  15.    (Start_Image "flp")
  16.    (Slide_Image 0 0 (Dimx_Tile "flp") (Dimy_Tile "flp") "flp")
  17.    (End_Image)
  18.    (action_tile "accept" "(readdata) (done_dialog 1)")
  19.    (action_tile "cancel" "(done_dialog 0)")
  20.    (setq re (Start_Dialog))
  21.   ))
  22.    (unload_dialog dcl_id)
  23. ))
  24. (if (= re 1 ) (progn
  25.   (setq pt (list x y 0.0))
  26.   (setq r2 (/ (+ r1 r3) 2))
  27.   (setq pt1 (polar pt (/ pi 2) (+ r3 3))
  28.              pt2 (polar pt (/ pi -2) (+ r3 3))
  29.              pt3 (polar pt pi (+ r3 3))
  30.              pt4 (polar pt 0 (+ r3 3))
  31.   )
  32.   (command "ltscale" "10")
  33.   (command "layer" "m" "0" "l" "continuous" "0" "c" "green" "0" "")
  34.   (command "circle" pt r1)
  35.   (command "circle" pt r3)
  36.   (command "circle" (polar pt 0 r2) r)
  37.   (command "array" "l" "" "p" pt n 360 "n")
  38.   (command "ltscale" "30")
  39.   (command "layer" "m" "1" "l" "center" "1" "c" "red" "1" "")
  40.   (command "circle" pt r2)
  41.   (command "line" pt1 pt2 "")
  42.   (command "line" pt3 pt4 "")
  43.   (command "redraw")
  44.   (setq area (* pi (- (* r3 r3) (* r1 r1) (* n r r))))
  45. ))
  46. (princ)
  47. )
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-17 13:42 , Processed in 0.164957 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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