Autodesk Inventor脚本打开.JT并导出.JT(带有特定选项)

问题描述 投票:0回答:1

我经常需要将现有的JT模型导出到tesselated JT模型,这需要花费很长时间在我的计算机上。所以我想知道这是否可以通过脚本完成?理想情况下嵌入在Excel文件中,我提供了一个JT文件名和路径列表,但是逐个也可以。只要我不必在Inventor中手动打开和导出每个文件。

需要设置的导入选项: - 对象过滤器:实体

导出选项: - 要导出的对象类型:全部勾选 - 输出:仅限构面 - 版本:9.5 - 结构:单片

可以这样做吗?我有一些VBA经验,但是就脚本/命令行的内容而言,绝对没有专门针对Inventor的经验....

谢谢!

dreamingof8a

vba autodesk autodesk-inventor
1个回答
0
投票

我目前没有选项的解决方案。但这是导出到JT的脚本。它基于Inventor API文档中的STEP示例。

Public Sub ExportToJT(inventorFile As String, jtFile As String)
    ' Get the JT translator Add-In.
    Dim oJTTranslator As TranslatorAddIn
    Set oJTTranslator = ThisApplication.ApplicationAddIns.ItemById("{16625A0E-F58C-4488-A969-E7EC4F99CACD}")

    If oJTTranslator Is Nothing Then
        MsgBox "Could not access JT translator."
        Exit Sub
    End If

    Dim oContext As TranslationContext
    Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
    Dim oOptions As NameValueMap
    Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
    If oJTTranslator.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, oContext, oOptions) Then

        ' Other options...
        'oOptions.Value("Author") = ""
        'oOptions.Value("Authorization") = ""
        'oOptions.Value("Description") = ""
        'oOptions.Value("Organization") = ""

        oContext.Type = kFileBrowseIOMechanism

        Dim oData As DataMedium
        Set oData = ThisApplication.TransientObjects.CreateDataMedium
        oData.FileName = jtFile

        Call oJTTranslator.SaveCopyAs(ThisApplication.ActiveDocument, oContext, oOptions, oData)
    End If
End Sub
© www.soinside.com 2019 - 2024. All rights reserved.