SolidWorks螺纹滚道旋风铣削多刀具渐进成形模拟仿真与分析(7)
时间:2017-05-30 09:59 来源:毕业论文 作者:毕业论文 点击:次
Dim f As Double f为进给量,单位m Dim π As Double π = 3.1415926535 在代码起始部分需要对使用到得变量进行定义和赋予初始值。而且需要注意的是在对话窗口中,输入的各数值单位是毫米和角度,在代码中,标准的单位是米和弧度,所以需要编写计算式后,才能直接使用,而且VB程序中没有对圆周率π进行定义,未进行赋初值的常量系统均赋予其初值0,所以此处要对π定义并赋值。 a = Val(TextBox1.Text) / 1000 b = Val(TextBox2.Text) * π / 180 c = Val(TextBox3.Text) / 1000 d = Val(TextBox4.Text) / 1000 + c e = 2 * π * Val(TextBox7.Text) / (Val(TextBox6.Text) * Val(TextBox8.Text)) f = -Val(TextBox5.Text) * Val(TextBox7.Text) / (1000 * Val(TextBox6.Text) * Val(TextBox8.Text)) 定义主要变量并赋值 Set swApp = Application.SldWorks Set Part = swApp.ActiveDoc Set SelMgr = Part.SelectionManager boolstatus = Part.Extension.SelectByID2("前视基准面", "PLANE", 0, 0, 0, False, 0, Nothing, 0) Part.SketchManager.InsertSketch True Part.ClearSelection2 True Dim SkCircle As Object Set SkCircle = Part.SketchManager.CreateCircle(0, 0, 0, 0, a, 0) 画出圆点为(0,0,0),半径为a的圆,如图4.1所示 图4.1 画出圆点为(0,0,0),半径为a的圆 Part.ClearSelection2 True Part.SketchManager.InsertSketch True Part.ShowNamedView2 "*上下二等角轴测", 8 Part.ClearSelection2 True boolstatus = Part.Extension.SelectByID2("草图1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0) Part.FeatureManager.FeatureExtrusion2 True, False, False, 0, 0, 0.1, 0, False, False, False, False, 0, 0, False, False, False, False, 1, 1, 1, 0, 0, False 如图4.2所示,进行拉伸,形成长度100mm的圆柱体 图4.2 拉伸圆柱体 Part.SelectionManager.EnableContourSelection = 0 boolstatus = Part.Extension.SelectByID2("", "FACE", 0, a, 0, True, 0, Nothing, 0) Part.InsertAxis2 True boolstatus = Part.Extension.SelectByID2("前视基准面", "PLANE", 0, 0, 0, False, 0, Nothing, 0) Part.SketchManager.InsertSketch True Part.ClearSelection2 True Dim SkLine As Object Set SkLine = Part.SketchManager.CreateLine(-0.04, 0.03, 0, -0.04, -0.03, 0) 如图4.3所示,画建立基准面1的辅助线,(-0.04,0.03,0)和(-0.04,0.03,0)为线段两端点 (责任编辑:qin) |