【问题标题】:Start an Instance of Autodesk Inventor启动 Autodesk Inventor 实例
【发布时间】:2013-08-14 18:37:20
【问题描述】:

我正在使用 Inventor api 来自定义发明者文档。这里我使用 vb.net 代码来启动 Inventor 的一个实例。我的代码是

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

没关系,工作正常。但是当我们以管理员身份打开 Visual Studio 时,createobject 出现了一些错误。有人知道启动 Inventor 实例的其他方法吗?

【问题讨论】:

  • 什么是“一些错误”?
  • 无法创建 ActiveX 组件。
  • 你在项目属性中引用了COM吗?

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


【解决方案1】:

尝试改用 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

【讨论】:

    【解决方案2】:
    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
    

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

    【讨论】:

      猜你喜欢
      • 2018-03-01
      • 2014-11-06
      • 2014-11-25
      • 2020-04-25
      • 2015-08-31
      • 2020-08-05
      • 2018-02-16
      • 2019-04-10
      • 2020-12-09
      相关资源
      最近更新 更多