Inventor Translator Class ID String

Inventor Translator Class ID String

ccoomes
Advocate Advocate
314 Views
2 Replies
Message 1 of 3

Inventor Translator Class ID String

ccoomes
Advocate
Advocate

I have created an iLogic rule that outputs the Translator name and Class ID String to a text file if anyone is interested.

 

Please excuse the code, as I suspect there are better ways or doing it, but it works for me...

Sub Main

	Dim oTextFileName As String = "C:\Temp\Translator AddIn CLSID List.txt"

	Dim oAddIns As ApplicationAddIns
	oAddIns = ThisApplication.ApplicationAddIns

	Dim oTransAddIn As TranslatorAddIn

	WritetoFile(oTextFileName, "Autodesk Inventor Translator AddIns Class ID String", False)

	Dim i As Integer = 1

	For i = 1 To oAddIns.Count
		Try
			oTransAddIn = oAddIns.Item(i)
			WritetoFile(oTextFileName, oTransAddIn.DisplayName & " - " & oTransAddIn.ClassIdString, True)
		Catch
		End Try
	Next

End Sub

Private Sub WritetoFile(TxtFileName As String, TextToAdd As String, Optional ByVal AppendToFile As Boolean = True)

	'Dim dateString = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss")
	'Dim TxtFileName As String = ThisDoc.PathAndFileName(False) & "_" & dateString & ".txt"

	If AppendToFile = True Then
		'____Open and append to an existing text file_______
		Dim oAppend As System.IO.StreamWriter
		'oFile = TxtFileName
		oAppend = IO.File.AppendText(TxtFileName)
		oAppend.WriteLine(TextToAdd)
		oAppend.Flush()
		oAppend.Close()
	Else
		'____Create and write to a text file_________________
		oWrite = System.IO.File.CreateText(TxtFileName)
		oWrite.WriteLine(TextToAdd)
		'oWrite.WriteLine("File Created on " & DateString)
		oWrite.WriteLine("")
		oWrite.Close()
	End If

End Sub
Accepted solutions (1)
315 Views
2 Replies
Replies (2)
Message 2 of 3

JelteDeJong
Mentor
Mentor
Accepted solution

@ccoomes wrote:

I suspect there are better ways or doing it


 That sounds like a challenge. What do you think of this?

Dim file As New System.IO.FileInfo("C:\Temp\Translator AddIn CLSID List.txt")
If file.Exists Then file.Delete()

Using writer = file.AppendText()
    writer.WriteLine("Autodesk Inventor Translator AddIns Class ID String")
    For Each addin As ApplicationAddIn In ThisApplication.ApplicationAddIns
        writer.WriteLine(addin.DisplayName & " - " & addin.ClassIdString)
    Next
End Using

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 3

ccoomes
Advocate
Advocate

@JelteDeJong thank you for the much simpler code than mine. I knew that there would be a much simpler and neater solution, but mine worked for me at the time.

 

Thank you for the code, I will update mine now.

0 Likes