




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
MechanicalCAD/CAMReportCADsecondarydevelopmentofthedrawboltAcademy:MechanicalandElectricalCollegeMajor:MechanicaldesignandmanufactureofbrakeClass:072093Name:聂俊杰StudentID:20091003886Expectscore:94June2012ContentsTOC\o"1-5"\h\z\o"CurrentDocument"CAD-basedlispsecondarydevelopmentofthebolts 1\o"CurrentDocument"lispProfile 1\o"CurrentDocument"Boltdesign 2\o"CurrentDocument"CAD-basedVBAsecondarydevelopmentofthebolts 5\o"CurrentDocument"2.1.VBAProfile 5\o"CurrentDocument"Boltdesign 5\o"CurrentDocument"Appendix: 101.AboltofLispprograms 102.AboltofVBAprograms 111.CAD-basedlispsecondarydevelopmentoftheboltslispProfileAutoLISPisaLISPprogramminglanguagedevelopedbyAutodesk,LISPstandsfortheListProcessor.Autolispprogramming,savingengineersMuchtime.TheAutoLISPprogramminglanguageembeddedwithinAutoCADwithsmartfeatures,isanindispensabletoolforthedevelopmentandapplicationofAutoCAD.AUTOLISPembeddedIntoAutoCADenablesuserstotakefulladvantageofAutoCADforsecondarydevelopment;directlyincrease,modifyAutoCADcommands,canbeextendedgraphicseditingfeatures,theestablishmentofGraphicslibraryanddatabaseandgraphicsdirectlyaccessandmodifythedevelopmentofCADsoftwarepackages.Typicalapplications:parametricdrawingprogramdesign,includingfootInchdriver,themousetodragtheprogram.Sofar,mostoftheparametricprogramarepreparedfortwo-dimensionalgraphics.Infact,thethree-dimensionalmapcanalsoachieveParametricDrawingAutoCADthree-dimensionalmapofthepreparationoftheentityparametricprogrammorethanitsthree-dimensionalviewoftheprogramissimple,andcaneasilygeneratethree-dimensionalmapgenerationafterthreeviews,Sectionsandaxonometricdrawing.ConstitutetheDCLfiletocreateyourowndialogbox.DrivetheuseofAutoCADprovidesthePDBmodulesDCLfiletocreateyourowndialogbox.CanAllofthecommandsdirectlyinAutoCAD.t'smainfunction:Languageis1.AutoLISPonthebasisofcommonLISPlanguage,theexpansionforCADapplications,specialfunctionsandtheformationofaonlytoexplaintheruninterpretativeprogramminglanguagewithinAutoCAD.2.AutoLISPlanguageallcomponentsaregivenintheformofafunction,itdoesnothaveastatementofconceptsorothergrammaticalstructures.TheimplementationoftheAutoLISPprogramistoperformsomefunction,
andthencallotherfunctions.3.AutoLISPdataandprogramstoaunifiedexpressionforthetablestructure,theS-expressionprocessing,itcanalsobetheprogramasdata,butalsothedataasaprogramtoperform.AutoLISPlanguageprogramisrunningisthefunctionevaluationprocess,thefunctionfunctioninthefunctionevaluationprocess.AutoLISPlanguagecontrolstructureisarecursiveway.Recursivelytheuseoftheprogramisdesignedtobesimpleandeasytounderstand.BoltdesignBoltsketchesaswellasthelengthasshowninFigure1-1,asshownbyp0,p0thestartingpoint,andthendeterminethecoordinatesofotherpoints.Thepreparatoryworkiscompleted,startwritingprograms.plO p9pllDld2p4pl2pOp8p7p60.ID2D—— ■■0.7DLFigure1-1BoltsketchstartupVisualLispMenu:Tools---AutoLisp---VisualLispEditorcreateaLispprojectClickFile-NewFile,intheeditwindow,enterthewrittenprocedure,theprocessshowninFigure1-2asshown;
Clicktoloadtheeditoractivewindowbuttoneditingwindowautomaticallyjumptotheconsole,enterintheconsole(c:functionname),showninFigure1-3;carriagereturn,automaticallyreturntoAutoCAD,followthepromptstoselectbasispoints,theinputboltdiameterandboltlength,thefinalCADautomaticallydrawtheboltsshowninFigure1-4;■VisualJ.ISP控制台剧血IFigure1-3ConsoleAutoCAD2010Dravingl.dvg观图⑦插入格式©工具①绘图@)标注@)修改观)参数窗口魁)帮助⑩剧血IFigure1-3ConsoleAutoCAD2010Dravingl.dvg观图⑦插入格式©工具①绘图@)标注@)修改观)参数窗口魁)帮助⑩ByLayer” [0.30mmV|BYruLZUlI甜令:经典□02;1表格从#<editor"C:/DocumentsandSettings/Administrator/^面/二次开发/ni—lsp"〉加载_$(c:drawnut)Figure1-4CADDrawingwindowAfterthesuccessoftheprogramisrunning,theconsoleshowninFigure1-5;Figure1-5Runafterthesuccessoftheconsole
Figure1-5Runafterthesuccessoftheconsole2.CAD-basedVBAsecondarydevelopmentofthebolts2.1.VBAProfileVBAnamelyMcrosoftofficeintheVisualBasicforApplications,itisintegratedintoAutoCAD2000.VBAprovidesanewchoicefordevelopers,thetechnologyframeworkbutalsoforuseraccessofAutoCAD2000toopenanewchannel.ThepowerfulcombinationofActiveXAutomationObjectModelVBAandAutoCAD2000,representsthearchitectureofanewtypeofcustomizationofAutoCADmodel.WithVBA,wecanoperateAutoCAD,controltheActiveX,andotherapplications,andmakeeachotherreciprocalactivities.BoltdesignBoltsketchesaswellasthelengthasshowninFigure1-1,asshownbyp0,p0thestartingpoint,andthendeterminethecoordinatesofotherpoints.Thepreparatoryworkiscompleted,startwritingprograms.dIQ p9Dllolo2 D.3_ 「1pl2d0p8p7p6 -P17P18 1ip21丿1rpl5pl60.ID2D—— p20?19 ・0.7DLFigure2-1Boltsketch
1.startupVBAMenu:Tools---Macro(A)---VisualBasicEditorShowninFigure2-2toopentheVBAeditor;Figure2-2VBAeditorwindow2.AddmoduleMenu:Insert(I)---Module(M)AddProcessMenu:Insert(I)---Process(P)Inthepop-upwindowtoenterluoshua,theoptionissetasshowninFigure2-3.
ClickOKtoopentheVBAEditorasshowninFigure2-4;Figure2-44.loadandrunprogramSetupaProcessNamedluoshuaWrittenproceduresenteredintotheeditwindowshowninFigure2-5,checkthecorrect,clicktheRunbuttontoruntheprogram;Figure2-5ProgramCodeinVBAEditor
WrittenproceduresenteredintotheeditwindowshowninFigure2-5,checkthecorrect,clicktheRunbuttontoruntheprogram;Figure2-5ProgramCodeinVBAEditorVBAeditorwindowtojumptotheCADwindow,showninFigure2-6.超(FJ 超(FJ 钿E] 视图MHXS血TM(T)绘图丽礙丽W(M)空数JpT鹽畫工具箱2而Vf窗口丽籲丽▼]|为Standard|口3日丨吕⑧耳①國|黑Q◎團空I®*Q“5?Q越©|罔MBE?鱼留圍〒]|/[1925 ▼]|为StandardT彥鲁镭!■ByLayerByLayer十卅 ByLayerBYCOLORT廳岡■编[9*厂T彥鲁镭!■ByLayerByLayer十卅 ByLayerBYCOLORT廳岡■编[9*厂卅■<>AutoCAD醪■HHI►|H[^gjXji^lXW2/丫命令: _ ,. _:命令:_vbaide正在初始化VBA系统•..l□□lITIrrlolal□l-/^^•lTulul”Idl□令■诅詁弓召Figure2-6CADwindowFollowthepromptstoselectbasispoints,pop-upinputdiameterdialog,enterthediameterofbolt,asshowninFigure2-7.Figure2-7EntertheboltdiameterFigure2-7Entertheboltdiameter确定确定ClickOK,thepop-upentertheboltlengthofthedialogboxwhereyouinputtheboltlength,asshowninFigure2-8.AutoCAD楚入摟栓啓取消Figure2-8inputtheboltlengthdialogboxAfteryouclickOK,CADautomaticallydrawtheboltsshowninFigure2-9.Enj;-1 Ci;|EMQ^lgBlffll^ls^iZT^^I^富皐i于b;5弐— :]|〔二一.■ 卬Figure2-9CADboltssincetheanimationAppendix:1.AboltofLispprograms(defunc:drawnut()(graphscr);窗口自动跳转(setqp0(getpoint"确定基点:"))(setqd(getreal"\n输入螺栓直径:"))(setq1d(getreal"\n输入螺栓长度:"))(if(>1d(*2d))(princ"ok!!")(setq1d(*2d)));判断螺栓长度是否大于2倍直径(setqp1(polarp0(*0.5pi)(*0.5d)))(setqp2(polarp10(-1d(*2d))))(setqp3(polarp10(-1d(*0.1d))))(setqp4(polarp2(*-0.5pi)(*0.1d)))(setqp5(polarp40(*2d)))(setqp6(polarp001d))(setqp7(polarp00(-1d(*0.1d))))(setqp8(polarp00(-1d(*2d))))(setqp9(polarp0(*0.5pi)d))(setqp10(polarp9pi(*0.7d)))(setqp11(polarp1pi(*0.7d)))(setqp12(polarp0pi(*0.7d)))(setqp13(polarp0pi(*1.2d)))(setqp14(polarp00(*1.21d)))(command"lweight"0.1);定义线宽(command"pline"p4p5"""color"1"");1红色2黄色,3绿色4青色5蓝色6洋红7白色(command"pline"p13p14"""color"7"")(command"lweight"0.3)(command"pline"p2p8"")(command"pline"p0p9p10p12"")(command"pline"p11p3p5p6"")(command"pline"p3p7"")(command"mirror""c"p10p6""p0p6"n");调用CAD镜像命令(princ))2.AboltofVBAprogramsPublicSubluoshua()DimLineObjAsAcadLine'定义直线的对象变量Dimp0AsVariantDimL,DAsDouble'定义长度和直径的数据类型Dimp1(0 To 2) As Double, p2(0 To 2) As Double, p3(0 To2) As DoubleDimp4(0 To 2) As Double, p5(0 To 2) As Double, p6(0 To2) As DoubleDimp7(0 To 2) As Double, p8(0 To 2) As Double, p9(0 To2) As DoubleDimp10(0To 2) As Double,p11(0 To 2) AsDouble,p12(0 To2)AsDoubleDimp13(0To2)AsDoubleDimp14(0To2)AsDouble,p15(0To2)AsDoubleDimp16(0To2)AsDouble,p17(0To2)AsDoubleDimp18(0To2)AsDouble,p19(0To2)AsDouble,p20(0To2)AsDoubleDimp21(0To2)AsDouble'定义各点坐标的数据类型p0=ThisDrawing.Utility.GetPoint(,"确定基点")'交换式输入基点D=Val(InputBox(〃输入螺栓直径〃))’交换式输入直径和长度L=Val(InputBox(〃输入螺栓长度〃))p1(0)=p0(0):p1(1)=p0(1)+0.5*D:p1(2)=p0(2)p2(0)=p1(0)+L-2*D:p2(1)=p1(1):p2(2)=p1(2)p3(0)=p2(0)+1.9*D:p3(1)=p2(1):p3(2)=p2(2)p4(0) = p2(0):p4(1)= p2(1) - 0.1*D:p4(2) =p2(2)TOC\o"1-5"\h\zp5(0) = p4(0)+2*D: p5(1) = p4(1):p5(2)= p4(2)p6(0) = p5(0):p6(1)= p5(1) - 0.4*D:p6(2) =p5(2)p7(0) = p6(0)-0.1*D:p7(1) =p6(1):p7(2) =p6(2)p8(0) = p6(0)-2*D: p8(1) = p6(1):p8(2)= p6(2)p9(0)=p0(0): p9(1) = p0(1)+D:p9(2)= p0(2)p10(0) = p9(0) - 0.7 * D: p10(1) = p9(1): p10(2) = p9(2)p11(0) = p1(0) - 0.7 * D: p11(1) = p1(1): p11(2) = p1(2)p12(0) = p0(0) - 0.7 * D: p12(1) = p0(1): p12(2) = p0(2)p13(0)=p12(0)-0.5*D:p13(1)=p12(1):p13(2)=p12(2)p14(0)=p6(0)+0.7*D:p14(1)=p6(1):p14(2)=p6(2)p15(0) = p2(0): p15(1) = p2(1) - D:p15(2)=p2(2)p16(0) = p3(0): p16(1) = p3(1) - D:p16(2)=p3(2)p17(0) = p4(0): p17(1) = p4(1) - 0.8*D:p17(2)= p4(2)p18(0) = p5(0): p18(1) = p5(1) - 0.8*D:p18(2)= p5(2)p19(0)=p9(0):p19(1)=p9(1)-2*D:p19(2)=p9(2)p20(0)=p10(0):p20(1)=p10(1)-2*D:p20(2)=p10(2)p21(0)=p11(0):p21(1)=p11(1)-D:p21(2)=p11(2)SetLineObj=ThisDrawing.ModelSpace.AddLine(p0,p9)SetLineObj
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025精装修房屋租赁合同
- 2025合同范本智慧之约
- 2025住宅买卖合同范本
- 2025机械设备购销合同
- 2025酒店总经理聘请合同范本
- 2025年标准城市写字楼租赁合同范本
- 2025年中国汽车维修合同
- 2025律师事务所劳动合同范本
- 2025医疗机构技术合作合同协议
- 2025企业高级管理人员聘请合同范本
- 国际经济学教案doc
- LY/T 3245-2020中国森林认证自然保护地森林康养
- 1新疆大学考博英语历年考博真题20-21年
- GB/T 11022-2020高压交流开关设备和控制设备标准的共用技术要求
- FZ/T 62033-2016超细纤维毛巾
- 答案-国开《中国近现代史纲要》形考任务:社会实践报告任务要求:在规定时间内完成分部组织的社会实践教学任务撰写社会实践报告并上传该任务占课程综合成绩的20%
- 生命教育讲座-课件
- 躲不开的食品添加剂讲解课件
- 农村常用法律法规知识讲座课件(村干部培训)
- 生活中的法律-国家开放大学电大学习网形考作业题目答案
- 焦点解决短期心理咨询与治疗理论课件
评论
0/150
提交评论