启动Autodesk Inventor实例

时间:2013-08-13 08:26:38

标签: asp.net vb.net autodesk autodesk-inventor

使用Inventor api自定义发明人文档。我使用vb.net代码启动Inventor的实例。我的代码是

 inventorApp = CreateObject("Inventor.Application", "")
 inventorApp.Visible = True

没关系,工作正常。但是当我们打开visual studio以管理员身份运行时,createobject会出现一些错误。任何人都知道启动Inventor实例的其他任何方式吗?

2 个答案:

答案 0 :(得分:0)

尝试使用marshal方法。

    Dim m_inventorApp As Inventor.Application
    Try ' Try to use active inventor instance

        Try
            m_inventorApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
            m_inventorApp.SilentOperation = True
        Catch ' If not active, create a new instance of Inventor
            Dim inventorAppType As Type = System.Type.GetTypeFromProgID("Inventor.Application")
            m_inventorApp = System.Activator.CreateInstance(inventorAppType)
            ' Must set visible explicitly
            m_inventorApp.Visible = True
            m_inventorApp.SilentOperation = True
        End Try
    Catch
        'Cant get or create an instance of inventor.
    End Try

答案 1 :(得分:0)

Private Sub Open_Button_Click()

ThisApplication.SilentOperation = True                'Suppresses the resolve links dialog

Dim myPath As String
myPath = FileName.Text                              'Gets the string, FileName, from module 1
Dim Shell As Object
Set Shell = CreateObject("Shell.Application")
Shell.Open (myPath)                                                      'Opens selected file

Resolve_and_Open.Hide                                               'Hides module

CompareStrings

End Sub

这是打开一个需要解析链接的悲伤程序集。我不确定这是否会解决该错误,但请尝试使用此:

ThisApplication.SilentOperation = True

要么是这样,要么创建一个shell然后以那种方式而不是直接打开它。