螺栓二次开发.docx

上传人:b****3 文档编号:4617038 上传时间:2022-12-07 格式:DOCX 页数:13 大小:622.97KB
下载 相关 举报
螺栓二次开发.docx_第1页
第1页 / 共13页
螺栓二次开发.docx_第2页
第2页 / 共13页
螺栓二次开发.docx_第3页
第3页 / 共13页
螺栓二次开发.docx_第4页
第4页 / 共13页
螺栓二次开发.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

螺栓二次开发.docx

《螺栓二次开发.docx》由会员分享,可在线阅读,更多相关《螺栓二次开发.docx(13页珍藏版)》请在冰豆网上搜索。

螺栓二次开发.docx

螺栓二次开发

MechanicalCAD/CAMReport

CADsecondarydevelopmentofthedrawbolt

 

 

Academy:

MechanicalandElectricalCollege

Major:

Mechanicaldesignandmanufactureofbrake

Class:

072093

Name:

聂俊杰

StudentID:

20091003886

Expectscore:

94

 

June2012

Contents

1.CAD-basedlispsecondarydevelopmentofthebolts1

1.1lispProfile1

1.2Boltdesign2

2.CAD-basedVBAsecondarydevelopmentofthebolts5

2.1.VBAProfile5

2.2Boltdesign5

Appendix:

10

1.AboltofLispprograms10

2.AboltofVBAprograms11

1.CAD-basedlispsecondarydevelopmentofthebolts

1.1lispProfile

AutoLISPisaLISPprogramminglanguagedevelopedbyAutodesk,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.4.AutoLISPlanguageprogramisrunningisthefunctionevaluationprocess,thefunctionfunctioninthefunctionevaluationprocess.5.AutoLISPlanguagecontrolstructureisarecursiveway.Recursivelytheuseoftheprogramisdesignedtobesimpleandeasytounderstand.

1.2Boltdesign

BoltsketchesaswellasthelengthasshowninFigure1-1,asshownbyp0,p0thestartingpoint,andthendeterminethecoordinatesofotherpoints.Thepreparatoryworkiscompleted,startwritingprograms.

Figure1-1Boltsketch

1.startupVisualLisp

Menu:

Tools---AutoLisp---VisualLispEditor

2.createaLispproject

ClickFile-NewFile,intheeditwindow,enterthewrittenprocedure,theprocessshowninFigure1-2asshown;

Figure1-2Inputprogram

3.Loadandruntheprogram

Clicktoloadtheeditoractivewindowbuttoneditingwindowautomaticallyjumptotheconsole,enterintheconsole(c:

functionname),showninFigure1-3;carriagereturn,automaticallyreturntoAutoCAD,followthepromptstoselectbasispoints,theinputboltdiameterandboltlength,thefinalCADautomaticallydrawtheboltsshowninFigure1-4;

Figure1-3Console

Figure1-4CADDrawingwindow

Afterthesuccessoftheprogramisrunning,theconsoleshowninFigure1-5;

Figure1-5Runafterthesuccessoftheconsole

2.CAD-basedVBAsecondarydevelopmentofthebolts

2.1.VBAProfile

VBAnamelyMcrosoftofficeintheVisualBasicforApplications,itisintegratedintoAutoCAD2000.VBAprovidesanewchoicefordevelopers,thetechnologyframeworkbutalsoforuseraccessofAutoCAD2000toopenanewchannel.ThepowerfulcombinationofActiveXAutomationObjectModelVBAandAutoCAD2000,representsthearchitectureofanewtypeofcustomizationofAutoCADmodel.WithVBA,wecanoperateAutoCAD,controltheActiveX,andotherapplications,andmakeeachotherreciprocalactivities.

2.2Boltdesign

BoltsketchesaswellasthelengthasshowninFigure1-1,asshownbyp0,p0thestartingpoint,andthendeterminethecoordinatesofotherpoints.Thepreparatoryworkiscompleted,startwritingprograms.

Figure2-1Boltsketch

1.startupVBA

Menu:

Tools---Macro(A)---VisualBasicEditor

ShowninFigure2-2toopentheVBAeditor;

Figure2-2VBAeditorwindow

2.Addmodule

Menu:

Insert(I)---Module(M)

3.AddProcess

Menu:

Insert(I)---Process(P)

Inthepop-upwindowtoenterluoshua,theoptionissetasshowninFigure2-3.

Figure2-3AddProcess

 

ClickOKtoopentheVBAEditorasshowninFigure2-4;

Figure2-4SetupaProcessNamedluoshua

4.loadandrunprogram

WrittenproceduresenteredintotheeditwindowshowninFigure2-5,checkthecorrect,clicktheRunbuttontoruntheprogram;

Figure2-5ProgramCodeinVBAEditor

VBAeditorwindowtojumptotheCADwindow,showninFigure2-6.

Figure2-6CADwindow

 

Followthepromptstoselectbasispoints,pop-upinputdiameterdialog,enterthediameterofbolt,asshowninFigure2-7.

Figure2-7Entertheboltdiameterdialog

ClickOK,thepop-upentertheboltlengthofthedialogboxwhereyouinputtheboltlength,asshowninFigure2-8.

Figure2-8Inputtheboltlengthdialogbox

AfteryouclickOK,CADautomaticallydrawtheboltsshowninFigure2-9.

Figure2-9CADboltssincetheanimation

 

 

Appendix:

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.AboltofVBAprograms

PublicSubluoshua()

DimLineObjAsAcadLine’定义直线的对象变量

Dimp0AsVariant

DimL,DAsDouble’定义长度和直径的数据类型

Dimp1(0To2)AsDouble,p2(0To2)AsDouble,p3(0To2)AsDouble

Dimp4(0To2)AsDouble,p5(0To2)AsDouble,p6(0To2)AsDouble

Dimp7(0To2)AsDouble,p8(0To2)AsDouble,p9(0To2)AsDouble

Dimp10(0To2)AsDouble,p11(0To2)AsDouble,p12(0To2)AsDouble

Dimp13(0To2)AsDouble

Dimp14(0To2)AsDouble,p15(0To2)AsDouble

Dimp16(0To2)AsDouble,p17(0To2)AsDouble

Dimp18(0To2)AsDouble,p19(0To2)AsDouble,p20(0To2)AsDouble

Dimp21(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)

p5(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=ThisDrawing.ModelSpace.AddLine(p9,p10)

SetLineObj=ThisDrawing.ModelSpace.AddLine(p10,p12)

SetLineObj=ThisDrawing.ModelSpace.AddLine(p11,p3)

SetLineObj=ThisDrawing.ModelSpace.AddLine(p3,p5)

SetLineObj=ThisDrawing.ModelSpace.AddLine(p5,p6)

SetLineObj=ThisDrawing.ModelSpace.AddLine(p4,p5)

SetLineObj=ThisDrawing.ModelSpace.AddLine(p2,p8)

SetLineObj=ThisDrawing.ModelSpace.AddLine(p3,p7)

SetLineObj=ThisDrawing.ModelSpace.AddLine(p0,p19)

SetLineObj=ThisDrawing.ModelSpace.AddLine(p19,p20)

SetLineObj=ThisDrawing.ModelSpace.AddLine(p20,p12)

SetLineObj=ThisDrawing.ModelSpace.AddLine(p21,p16)

SetLineObj=ThisDrawing.ModelSpace.AddLine(p16,p18)

SetLineObj=ThisDrawing.ModelSpace.AddLine(p18,p17)

SetLineObj=ThisDrawing.ModelSpace.AddLine(p16,p7)

SetLineObj=ThisDrawing.ModelSpa

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 初中教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1