iCAx开思网

标题: selectbyID2类型不匹配 [打印本页]

作者: xdhong    时间: 2010-12-1 16:15
标题: selectbyID2类型不匹配
我第一次用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
作者: xdhong    时间: 2010-12-1 19:22
怎么没人回复呢?急急
作者: 0010575853    时间: 2011-7-1 13:11
试试在引用例添加 Solidworks 20XX Type Library




欢迎光临 iCAx开思网 (https://www.icax.org/) Powered by Discuz! X3.3