马上注册,结交更多同行朋友,交流,分享,学习。
您需要 登录 才可以下载或查看,没有帐号?注册
x
请教:
用vb二次开发sw时,生成零件图时总是弹出错误:“对象变量或with块变量未设置”
程序如下:
Dim SwApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long
Dim featuredata As Object
Dim feature As Object
Set SwApp = CreateObject("SldWorks.Application") '引用SOLIDWORKS对象
SwApp.Visible = True '设置SolidWorks对象为可见
Set Part = SwApp.ActiveDoc '激活现有文档
Part.SelectByID "Plane1", "PLANE", 0, 0, 0 '激活plane1平面
Part.InsertSketch '激活草图绘制
Set Part = SwApp.NewDocument("D:\ProgramFiles\SolidWorks\lang\chinese-simplified\Tutorial\part.prtdot", 0, 0#, 0#)
'Solidworks坐标单位为米,故乘以0.001将mm转换为m.
For i = 0 To 15
x(i) = 0.5 * Db * 0.001 * (Sin(u * i / 15) - (u * i / 15) * Cos(u * i / 15))
y(i) = 0.5 * Db * 0.001 * (Cos(u * i / 15) + (u * i / 15) * Sin(u * i / 15))
Next i
For i = 0 To 15
x(i) = x(i) - 0.001 * 0.5 * sb
y(i) = y(i) - 0.001 * (0.5 * Db - Sqr((0.5 * Db) ^ 2 - (0.5 * sb) ^ 2))
Next i
'样条曲线拟合
For i = 0 To 15 Step 1 'y轴左侧齿廓
Part.SketchSpline 15 - i, x(i), y(i), 0
......
一般调试到Part.SketchSpline 15 - i, x(i), y(i), 0这一句就会出现上述错误。
还有调试的时候能不能从当前位置开始啊?一直从开头开始 运行好慢 |