iCAx开思网

标题: 关于API帮助文档内代码的疑问求助 [打印本页]

作者: 东边wo    时间: 2014-11-20 23:24
标题: 关于API帮助文档内代码的疑问求助
本帖最后由 东边wo 于 2014-11-21 09:29 编辑






问题1,我按照帮助文档的代码引用,编译器却提示如上错误(
在项目引用管理器里面我就选择下面三项,没问题吧)
问题2,下面代码蓝底的“swApp”是哪来的,找不到申明
问题3,我看到网上好多都是用“
swApp = CreateObject("SldWorks.Application")”引用接口的,为什么呢


Imports
SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System.Runtime.InteropServices
Imports System
Imports System.Diagnostics


Partial Class SolidWorksMacro

   
Dim swModel As ModelDoc2
   
Dim selMgr As SelectionMgr
   
Dim swPart As PartDoc
   
Dim mirrorFeature As Feature
   
Dim myFeature As Feature
   
Dim resultPart As ModelDoc2
   
Dim mirrorFeatData As MirrorPartFeatureData
   
Dim refPlane As RefPlane
   
Dim facePlane As Face2
   
Dim mirrorOptions As Integer
    Dim faceType As Integer
    Dim selType As swSelectType_e
   
Dim message As String

    Sub main()

        swModel = swApp.ActiveDoc

        
If swModel Is Nothing Then Exit Sub
        If swModel.GetType <> swDocumentTypes_e.swDocPART Then Exit Sub

        selMgr = swModel.SelectionManager

        
If selMgr.GetSelectedObjectCount2(-1) = 0 Then Exit Sub

        selType = selMgr.GetSelectedObjectType3(1, -1)
        
If Not (selType = swSelectType_e.swSelDATUMPLANES Or selType = swSelectType_e.swSelFACES) Then Exit Sub

        swPart = swModel

      

    .............字数限制,省略
        
End If

    End Sub


    Public swApp As SldWorks


End Class

作者: 东边wo    时间: 2014-11-21 09:30
为什么图片无法显示出来{:soso_e105:}





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