Anonymous
590 Views, 3 Replies
11-24-2018
03:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-24-2018
03:42 PM
Macro to save geometry as .jt doesnt use .cfg file. How do i get inventor to use the cfg file I specify?
Solved! Go to Solution.
Anonymous
in reply to:
Anonymous
11-30-2018
09:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-30-2018
09:33 AM
You would have to pass in the relevant options to the TraslatorAddin as a NameValueMap. The options for Config File are as follows:
ConfigFilePath String
ConfigFileEnabled Boolean (False)
Search Translator Options in API Help for more details on the available options.
Syntax of SaveCopyAs Method of TranslatorAddIn Object
TranslatorAddIn.SaveCopyAs( SourceObject As Object, Context As TranslationContext, Options As NameValueMap, TargetData As DataMedium )
Anonymous
in reply to:
Anonymous
12-02-2018
11:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
12-02-2018
11:58 AM
Reasonably cleaned up version of final code:
Function func_ConvertFolderContentToJT(ByVal strSourceFolder As String, ByVal strSourceFileType As String, ByVal strDestinationFolder As String, ByVal strDestinationFileType As String, ByVal strConverterConfigFilePath As String) As Boolean
func_ConvertFolderContentToJT = True
Dim objFS As FileSystemObject
Set objFS = CreateObject("Scripting.FileSystemObject")
If Right(strSourceFolder, 1) <> "\" Then
strSourceFolder = strSourceFolder & "\"
End If
If objFS.FolderExists(strSourceFolder) <> True Then
func_ConvertFolderContentToJT = False
Exit Function
End If
If strDestinationFolder <> "" Then
If objFS.FolderExists(strDestinationFolder) <> True Then
strDestinationFolder = False
End If
If Right(strDestinationFolder, 1) <> "\" Then
strDestinationFolder = strDestinationFolder & "\"
End If
End If
If strSourceFileType = "" Then
func_ConvertFolderContentToJT = False
Exit Function
End If
If strDestinationFileType = "" Then
func_ConvertFolderContentToJT = False
Exit Function
End If
Dim strToLookFor As String
strToLookFor = strDestinationFileType
If Left(strDestinationFileType, 1) = "." Then
strToLookFor = Right(strDestinationFileType, Len(strDestinationFileType) - 1)
Else
strToLookFor = strDestinationFileType
strDestinationFileType = "." & strDestinationFileType
End If
If objFS.FileExists(strConverterConfigFilePath) = False Then
func_ConvertFolderContentToJT = False
Exit Function
End If
Dim flg_TranslationAddInFound As Boolean
flg_TranslationAddInFound = False
Dim intAddIn As Long
intAddIn = 1
Do
If InStr(1, UCase(ThisApplication.ApplicationAddIns.Item(intAddIn).Description), UCase(strToLookFor)) > 0 Then
flg_TranslationAddInFound = True
Exit Do
End If
intAddIn = intAddIn + 1
Loop Until intAddIn = ThisApplication.ApplicationAddIns.Count + 1
If flg_TranslationAddInFound <> True Then
func_ConvertFolderContentToJT = False
Exit Function
End If
Dim JTAddIn As TranslatorAddIn
Set JTAddIn = ThisApplication.ApplicationAddIns.ItemById(ThisApplication.ApplicationAddIns.Item(intAddIn).ClientId)
Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
Dim oDataMedium As DataMedium
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
Dim objFolder As Folder
Dim objFile 'As File
Set objFolder = objFS.GetFolder(strSourceFolder)
Debug.Print "Convert Content of Folder: " & strSourceFolder
For Each objFile In objFolder.Files
Dim strFullFilePath As String
strFullFilePath = objFile
If Right(objFile, Len(strSourceFileType)) = strSourceFileType Then
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.Documents.Open(strFullFilePath)
If JTAddIn.HasSaveCopyAsOptions(oPartDoc, oContext, oOptions) = True Then
oOptions.Value("ConfigFilePath") = strConverterConfigFilePath
oOptions.Value("ConfigFileEnabled") = True
oContext.Type = kFileBrowseIOMechanism
If strDestinationFolder <> "" Then
strFullFilePath = Replace(strFullFilePath, strSourceFolder, strDestinationFolder)
End If
oDataMedium.FileName = strFullFilePath & strDestinationFileType
JTAddIn.SaveCopyAs oPartDoc, oContext, oOptions, oDataMedium
oPartDoc.Close True
Else
If strDestinationFolder <> "" Then
strFullFilePath = Replace(strFullFilePath, strSourceFolder, strDestinationFolder)
End If
oPartDoc.SaveAs strFullFilePath & strDestinationFileType, True
oPartDoc.Close True
End If
End If
Next objFile
End Function