AUTOLISP上机作业.docx
《AUTOLISP上机作业.docx》由会员分享,可在线阅读,更多相关《AUTOLISP上机作业.docx(14页珍藏版)》请在冰豆网上搜索。
AUTOLISP上机作业
过程装备与控制工程专业
过程装备CAD技术
上机作业
班级:
:
学号:
年月
第三题
(1)
;;;变量说明
;;;p0是圆脸中心,p1、p2是眼睛中心,p3是鼻子中心,p4、p5是嘴的两端点
;;;R---圆脸半径,r1---眼睛半径,r2---鼻子半径
(initget1)
(setqp0(getpoint"输入圆脸中心点:
"))
(initget(+124))
(setqR(getreal"输入圆脸半径值:
"))
(command"circle"p0R)
(setqr1(/R4.0))
(setqr2(/R9.0))
(setqp1(polarp0(/pi6.0)(/R2.0)))
(command"circle"p1r1)
(setqp2(polarp0(/(*pi5.0)6.0)(/R2.0)))
(command"circle"p2r1)
(setqp3(polarp0(-(/pi2.0))(/R4.0)))
(command"circle"p3r2)
(setqa(/(*R2.0)3.0))
(setqp4(polarp0(-(/(*pi3.0)4.0))a))
(setqp5(polarp0(-(/pi4.0))a))
(command"arc""c"p0p4p5)
(setqp6(polarp0(/pi6.0)(/R4.0)))
(setqp7(polarp0(/(*pi5.0)6.0)(/R4.0)))
(command"hatch""solid"p6"")
(command"hatch""solid"p7"")
第三题
(2)
;;;变量说明
;;;plw---线宽
(initget1)
(setqp0(getpoint"输入左下角点:
"))
(setqplw1.0)
(setqa100)
(setqb150)
(setqc(/pi2.0))
(setqd(-(/pi2.0)))
(setqp1(polarpoca))
(setqp2(polarp10b))
(setqp3(polarp2ca))
(setqp4(polarp30b))
(setqp5(polarp4da))
(setqp6(polarp50b))
(setqp7(polarp6da))
(command"pline"p0"w"plew""p1p2p3"w"0""p4p5p6p7"c")
第三题(3)
(initget1)
(setqp0(getpoint"输入起点位置:
"))
(initget1)
(setqbb(getreal"输入圆心连线与水平线夹角="))
(setqaa(/(*bbpi)180.0))
(initget(+124))
(setqn(getint"圆的个数="))
(initget(+124))
(setqr(getreal"圆的半径="))
(setqd(*r2.0))
(repeatn
(command
"circle"p0r
);;endofcommand
(setqp0(polarp0aad))
);;endofrepeat
第五题
(setqp0'(100100))
(setqr200)
(setqp1'(400100))
(command"circle"p0r)
(setqe1(ssget"L"))
(command"offset"30e1p1"")
第六题
;;;变量说明:
p0为图形中心,R为正五边形外接圆半径,R1为中心圆半径,a为正五边形边长。
(initget1)
(setqp0(getpoint"指定p0点:
"))
(initget(+124))
(setqR(getreal"输入正五边形外接圆半径:
"))
(setqR1(/R2.0))
(command"circle"p0R1)
(setqs1(entlast))
(setqd(-(*pi(/126.0180))))
(setqp1(polarp0dR))
(setqb(*pi(/36.0180)))
(setqa(*2.0R(sinb)))
(setqp2(polarp10a))
(setqp5(polarp1(*(/108.0180)pi)a))
(setqp3(polarp2(*(/72.0180)pi)a))
(setqp4(polarp0(/pi2.0)R))
(command"pline"p1p2p3p4p5"c")
(setqs2(entlast))
(setqp6(list(carp1)(-(cadrp1)50.0)))
(setqp7(list(carp2)(-(cadrp2)50.0)))
(command"mirror"s1s2""p6p7"")
第七、九题
(1)DCL文件:
lx1:
dialog{
label="练习";
spacer;
children_fixed_width=true;
:
popup_list{/*popup_list*/
label="弹出式列表";
key="plist1";
width=18;
}/*endofpopup_list*/
spacer_1;
:
edit_box{/*edbox_1*/
label="编辑框";
key="edbox";
width=18;
}/*endofedbox_1*/
spacer_1;
ok_cancel;
}/*endofdialog*/
(2)驱动程序:
(defunmainprogram();;主程序
(setqplist_1(list"200""300""400"));;弹出式列边框中的容
(setqplist_2(list200300400));;编辑框中的容
(setqshuzhi"200")
(liebiao);;调用列表函数
);;endofdefunmainprogram
(defunliebiao()
(if(>(setqdlg_id1(load_dialog"c:
\\users\\Administrator\\desktop\\dialog_column1.dcl"))0);;加载对话框文件
(progn;;progn1
(if(new_dialog"lx1"dlg_id1);;显示对话框
(progn;;progn2以下初始化对话框和描述控件活动
(start_list"plist1");;初始化弹出式列表框
(mapcar'add_listplist_1)
(end_list)
(set_tile"edbox""200");;初始化编辑框
(action_tile"plist1""(plistaction)");;列表框有动作时调用函数plistaction
(start_dialog);;激活对话框
);;endofprogn2
(alert"Unabletodisplaydialogbox")
);;endofnew_dialog
(unload_dialogdlg_id1);;卸载对话框
);;endofprogn1
(alert"Unabletoloaddialogbox")
);;endofload_dialog
);;endofdefunliebiao
(defunplistaction(/a)
(setqa(get_tile"plist1"));;得到列表的索引值
(setqa(atoia))
(setqshuzhi(nthaplist_2))
(setqshuzhi(rtosshuzhi20));;将相应的数值转换成字符串
(set_tile"edbox"shuzhi);;在编辑框中显示数值
);;endofdefunplistaction
第十题
(1)DCL文件:
id0:
dialog{
label="算属相";
spacer;
children_fixed_width=true;
:
edit_box{
label="出生年份:
";
key="edbox1";
width=28;
}
:
text{
label="(如1956)";
}
:
row{//row1
:
text{
label="属相:
";
}
:
column{//column1
:
text{
width=20;
key="txt1";
}
}//endofcolumn1
}//endoflow1
spacer;
ok_only;
spacer;
}//endofdialog
(2)驱动程序:
(defunid0()
(if(>(setqdlg_id(load_dialog"C:
\\Users\\Administrator\\Desktop\\dialog_id0.dcl"))0);;加载对话框文件
(progn;;progn1
(if(new_dialog"id0"dlg_id)
(progn;;progn2
;;以下初始化对话框和描述控件活动
(action_tile"edbox1""(edbox1action)")
;;以上初始化对话框和描述控件活动
(start_dialog);;激活对话框
);;endofprogn2
(alert"Unabletodisplaydialogbox")
);;endofnewdialog
(unload_dialogdlg_id);;卸载对话框
);;endofprogn2
(alert"Unabletoloaddialogbox")
);;endofloaddialog
);;endofdefun
(defunedbox1action()
(setqidnum(get_tile"edbox1"))
(setqidnum(atoiidnum))
(setqidnum(remidnum12))
(set_tile"txt1"(cond((=idnum0)"猴")
((=idnum1)"鸡")
((=idnum2)"狗")
((=idnum3)"猪")
((=idnum4)"鼠")
((=idnum5)"牛")
((=idnum6)"虎")
((=idnum7)"兔")
((=idnum8)"龙")
((=idnum9)"蛇")
((=idnum10)"马")
((=idnum11)"羊")
);;endofcond
);;endofset_tile
);;endofdefunedbox1action
第十三题
MNU文件:
***pop1
[作业]
[第九题...]^c^c(load"C:
/Users/Administrator/Desktop/dialog_column1.lsp")(mainprogram)
[第十题...]^c^c(load"C:
/Users/Administrator/Desktop/第10题驱动程序.lsp")(id0)