明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1557|回复: 5

请大家帮个小忙!

[复制链接]
发表于 2004-3-23 20:37:00 | 显示全部楼层 |阅读模式
(defun c:desk2()
(setvar "cmdecho" 0)
(dcl_desk2)
(prin1)
)
(defun dcl_desk2()
(setq dcl_id (load_dialog "desk2"))
(new_dialog "desk2" dcl_id)
(set_tile "x" "0")
(set_tile "y" "0")
(set_tile "width" "0")
(set_tile "height" "0")
(set_tile "length1" "0")
(set_tile "rad" "0")
;;;;(action_tile "draw_desk2" "(get_number)(done_dialog 1)")
(action_tile "ins_ok" "(draw_desk2)(done_dialog 1)")
(setq bb(start_dialog))
(cond ((= bb 1) (draw_desk2))
(t (alert "未完成任何动作,要退出请确定!"))
)
(start_dialog)
(prin1)

)
(defun get_number()
(setq d_x(rtos (get_tile "x")));;;;;实数转字符串
(setq d_y(rtos (get_tile "y")))
(setq d_width(rtos (get_tile "width")))
(setq d_height(rtos (get_tile "height")))
(setq d_length(rtos (get_tile "length1")))
(setq d_rad(rtos (get_tile "rad")))
; (setvar d_mcolor(atof (get_tile "mcolor")))
; (setvar d_tcolor(atof (get_tile "tcolor")))
)
(defun get_number1()
(setq x(atof (get_tile "d_x")));;;;;字符串转换成实数atof ;;atoi字符串转换成整数
(setq y(atof (get_tile "d_y")))
(setq width(atof (get_tile "d_width")))
(setq height(atof (get_tile "d_height")))
(setq length1(atof (get_tile "d_length")))
(setq rad(atof (get_tile "d_rad")))
; (setvar d_mcolor(atof (get_tile "mcolor")))
; (setvar d_tcolor(atof (get_tile "tcolor")))
)
(defun draw_desk2()
;(setq l1 (getpoint "输入左下角点:"))
;(setq xx (getreal "宽度h:"))
;(setq yy (getreal "高度:"))
;(setq zz (getreal "长度:"))
;(setq tt (getreal "半径:"))
(get_number)
(get_number1)
(setq l2 (polar x 0 (/ length1 4)))
(setq l3 (polar l2 0 (/ length1 2)))
(setq c1 (polar l2 (/ pi 2) (/ height 4)))
(setq c2 (polar c1 (/ pi 2) (/ height 2)))
(setq c3 (polar l3 (/ pi 2) (/ height 4)))
(setq c4 (polar c3 (/ pi 2) (/ height 2)))
;;;;
(command "box" x "l" length1 height width "c")
(command "cylinder" c1 rad length1 "c")
(command "cylinder" c2 rad length1 "c")
(command "cylinder" c3 rad length1 "c")
(command "cylinder" c4 rad length1 "c")
(command "box" x "l" length1 height width "c")
(command "box" x "c" height "c")
(command "-view" "swiso")
(command "shademode" "g")
(prin1)
(prin1)
) 这个是.lsp源文件
desk2:dialog{
label="CAD二次开发—凳子参数设计框";
:text{
label="请在图中选取一点或直接输入点X和Y坐标";
alignment=centered;
}
:row{
:boxed_column{
label="参数设计一";
fixed_width=true;
fixed_height=true;
width=2;
height=1;
:edit_box{label="X坐标";
key="x";
edit_width=5;} :edit_box{label="Y坐标";
key="y";
edit_width=5;} :edit_box{label="宽度";
key="width";
edit_width=5;} :edit_box{label="高度";
key="height";
edit_width=5;} :edit_box{label="长度";
key="length1";
edit_width=5;} :edit_box{label="半径";
key="rad";
edit_width=5;}
}
:boxed_column {
label="参数设计二";
fixed_width=true;
fixed_height=true;
width=2;
height=1;
color_palette_1_9;
spacer_1;
color_palette_250_255;
spacer_1;
:row{
:text{label="面颜色";alignment=centered;}
:image{
//key="m_color";
color=7;
width=6;
aspect_ratio=1;
}
:text{label="腿颜色";alignment=centered;}
:image{
//key="t_color";
color=7;
width=6;
aspect_ratio=1;
}
}
spacer_1;
:row{
fixed_width = true;
alignment = centered;
:button{
label="确定";
key="ins_ok";
width=8;
}
: spacer {width =2;}
cancel_button;}
}
}
}
这个是.dcl文件! 我想实现的功能就是,可以在对话框.dcl文件里设置参数,然后直接可以画出图!可总是觉得.dcl 和lsp链接不起来!总是出现些错误! 跪请大家帮我分析分析啊
发表于 2004-3-23 21:24:00 | 显示全部楼层
为什么要执行两次(draw_desk2),而且此函数中含有command,在没有退出对话框的情况下执行command是会出错的,你的第一次执行(draw_desk2)时还未退出对话框,初步认为这个是多余的
 楼主| 发表于 2004-3-23 21:41:00 | 显示全部楼层
首先感谢斑竹的热情帮助,小弟在这里谢谢您了! ;;;;(action_tile "draw_desk2" "(get_number)(done_dialog 1)")
这一行我加了分号是多余的,今天看书的时候也看到过,在对话框没有结束前,command是错误的。 其实这个程序就是设计个凳子,(defun draw_desk2()
;(setq l1 (getpoint "输入左下角点:"))
;(setq xx (getreal "宽度h:"))
;(setq yy (getreal "高度:"))
;(setq zz (getreal "长度:"))
;(setq tt (getreal "半径:"))
(get_number)
(get_number1)
(setq l2 (polar x 0 (/ length1 4)))
(setq l3 (polar l2 0 (/ length1 2)))
(setq c1 (polar l2 (/ pi 2) (/ height 4)))
(setq c2 (polar c1 (/ pi 2) (/ height 2)))
(setq c3 (polar l3 (/ pi 2) (/ height 4)))
(setq c4 (polar c3 (/ pi 2) (/ height 2)))
;;;;
(command "box" x "l" length1 height width "c")
(command "cylinder" c1 rad length1 "c")
(command "cylinder" c2 rad length1 "c")
(command "cylinder" c3 rad length1 "c")
(command "cylinder" c4 rad length1 "c")
(command "box" x "l" length1 height width "c")
(command "box" x "c" height "c")
(command "-view" "swiso")
(command "shademode" "g")
(prin1)
(prin1)
) 这个程序在没有加对话框以前都运行试过了(小毛病就是值必须设置的恰当)还有调试的时候对话框也能出来,就是设置完数值以后确定就出现错误,无法 画图了:*恩我明天再调试调试 还想问大家个问题 如何在对话框里输入了数值以后,可以画出相应的图啊?
 楼主| 发表于 2004-3-24 19:23:00 | 显示全部楼层
没有人帮帮我啊!
发表于 2004-3-24 20:13:00 | 显示全部楼层
可以画了,随便给了几个参数,那哪是凳子?!


       

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2004-4-1 21:00:00 | 显示全部楼层
谢谢你了,前些天不能上网,所以没有来,谢谢了,我们在搞毕业设计这只是调试个小程序,哎,烦死了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-10-1 17:36 , Processed in 0.170354 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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