资源描述:
《程序代码及解释》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、程序代码及解释1、optionexplicit设罝显示变量声明2、Dimswappasobject定义各变量3、Dimpartasobject4、Dimsksegmentasobject5、Dimvsklinesasvariant6、Dimmyfeatureasobject7、Dimboolstatusasboolean8、Dimlongstatusaslongjongwarningsaslong9、Dimmydisplaydimasobject10、Privatesubcommand2_click()革击command2按钮时退出程序11、End12、Endsub13
2、、Privatesubcommandl_click()早击commandl按钮吋执行程序14、Setswapp=createobject("sldworks.application”)创建sldworks对象15、Swapp.visible=ture设置显示SolidWorks程序界面16、Setpart=swapp.Newdocument(c;documentsandsettingsAIIusersapplicationdatasolidworks2009templates零件I)17、Setpart=swappactivedoc激活文件18、Boolst
3、atus=partextensionselectbylD2(上视基准面,plane,0,0,0tales,0,nothing,0)选择上视基准面19、Partsketchmanagerinsertsketchture开始草图绘制20、Setsksegment=part.sketchmanager.creatcirclebyradius(0#,0#,Off,0.033)绘制半径为33的圆21、Setmyfeature=part.featuremanager.featureextrusion(true,false,false,0,0,0.015,0.01,false,fal
4、sefalse,false,0.01745329251994,0.01745329251994Jalse,false,false,false,true,true,true)对圆进行单向拉伸,形成头部圆柱体22、Boolstatus=part.extension.selectbylD2(“上视基准面”,“PLANE”,0,0,O.FALSE,O,NOTHING/))选择上视基准面23、Part.sketchmanager.insertsketchtrue24、Setsksegment=part.sketchmanager.createcirclebyradius(0#,0
5、#z0#,0.03)绘制半径为30的圆25、Setmyfeature=part.featuremanager.featureextrusion(true,false,true,0,0,0.001,0.015,false,false,false,falseO.01745329251994,0.01745329251994,false,false,false,false,true,true,true)对阅进行单向拉伸,形成头部阅柱体26、Boolstatus=part.extension.selectbyid2("","face",-5.673938468647e-04.-
6、9.999999999764e-04,0.01782047016349,false,0,nothing,0)选择拉伸2形成的短柱体底面27、Part.sketchmanager.insertsketchtrue28、Setsksegment=part.sketchmanager.createcirclebyradius(0#,0#,0#z0.024)绘制半径为24的圆29、Setmyfeature=part.featuremanager.featureextrusion(true,false,false,0,0,0.03,0.001,false,false,false/
7、alse,true,true,true)对圆进行单向拉伸,形成长柱体30、Boolstatus=part.extension.selectbyid2("前视基准面",“plane”,0,0,0,false,0,nothing,0)选择前视基准面31、Part.sketchmanager,insersketchtrue32、Setsksegment=part.sketchmanager.createcenterline(0#,0#,0#,0#,0.02,0#)绘制屮心线33、Setsksegment=part.sketchmanager.c