|
马上注册,结交更多同行朋友,交流,分享,学习。
您需要 登录 才可以下载或查看,没有帐号?注册
x
我第一次用VS2008中的VB 对SOLIDWORKS2008进行二次开发,就画一个方块,录制宏代码,但调试总出现未处理的COMException,类型不匹配。异常来自 HRESULT:0x80020005 (DISP_E_TYPEMISMATCH))。
求助各位这是怎么回事,应该怎么改啊?
原代码如下:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim swapp As Object
Dim Part As Object
Dim SelMgr As Object
Dim Boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Dim strpth As String
swapp = CreateObject("SldWorks.Application") ' 建立联接
Part = swapp.newpart ' 新建零件
Part = swapp.ActiveDoc
SelMgr = Part.SelectionManager
Boolstatus = Part.Extension.SelectByID2("前视基准面", "PLANE", 0, 0, 0, False, 0, Nothing, 0) (此句出现问题)
Part.SketchManager.InsertSketch(True)
Part.ClearSelection2(True)
Dim vSkLines As Object
vSkLines = Part.SketchManager.CreateCornerRectangle(-0.05, 0.025, 0, 0.05, -0.025, 0)
Part.EditCopy()
Part.ClearSelection2(True)
Boolstatus = Part.Extension.SelectByID2("Line1", "SKETCHSEGMENT", -0.003716687309331, 0.02155678639412, 0, False, 0, Nothing, 0)
Boolstatus = Part.Extension.SelectByID2("Line2", "SKETCHSEGMENT", -0.03939688547891, -0.008474047065275, 0, False, 0, Nothing, 0)
Part.ClearSelection2(True)
Boolstatus = Part.Extension.SelectByID2("Line2", "SKETCHSEGMENT", -0.04028889043315, -0.004311357278824, 0, False, 0, Nothing, 0)
Part.ClearSelection2(True)
Part.SketchManager.InsertSketch(True)
Part.ShowNamedView2("*上下二等角轴测", 8)
Part.SketchManager.InsertSketch(True)
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.01, 0.01, False, False, False, False, 0.01745329251994, 0.01745329251994, False, False, False, False, 1, 1, 1, 0, 0, False)
Part.SelectionManager.EnableContourSelection = 0
swapp = Nothing
Part = Nothing
End Sub
End Class |
|