Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Hi Alex,

It looks like the problem with icons in case of iLogic rule has surprisingly simple solution suggested by Mike Deck.

 

In VB.NET (and thus iLogic), Enum members (constants) must be qualified with their type name.

To find the type name, search for the enum (in Inventor, almost all enum constants start with the letter k)

in the Inventor API help. Searching for kOLEDocumentLinkObject,  you will find the OLEDocumentTypeEnum page.

 

To help detect these constants in code, you can add the statement

        Option Explicit On

at the top of the rule. This will require that all variables be declared explicitly.

 

So I've added "Option Explicit On" in the first line, and then added OLEDocumentTypeEnum  qualifier to both constants kOLEDocumentLinkObject.

Other minor changes do not influence to the icons and were added to simplify code a little.

Here is my final version.  This code works both in Inventor 2014 and 2015.

 
Option Explicit On

'current document
Dim doc as Inventor.Document = ThisDoc.Document

'Verify the current document has been saved.
If doc.FullFileName = "" Then
	MessageBox.Show("This document must be saved first.")
	Exit Sub
End If

'default folder
Dim FolderName As String  = Left$(doc.FullFileName, InStrRev(doc.FullFileName, "\") )	
Dim selectedfile As String = String.Empty
Dim oFileDlg As inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
'oFileDlg.Filter = "Dwg files (*.dwg)|*.dwg|Excel files (*.xlsx)|*.xlsx|pdf files (*.pdf)|*.pdf|Inventor parts (*.ipt)|*.ipt"
oFileDlg.InitialDirectory = FolderName
oFileDlg.CancelError = True
oFileDlg.MultiSelectEnabled = True

Try
	oFileDlg.ShowOpen()
	selectedfile = oFileDlg.FileName
Catch
	Return  'operation was cancelled by the user
End Try

Dim oleReference As ReferencedOLEFileDescriptor
If selectedfile.Contains("|") Then ' we have multiple files selected.
	Dim file As String() = selectedfile.Split("|")
	For Each s as String in file
		oleReference = doc.ReferencedOLEFileDescriptors _
			.Add(s, OLEDocumentTypeEnum.kOLEDocumentLinkObject)
		oleReference.BrowserVisible = True
		oleReference.Visible = False
		oleReference.DisplayName = Mid$(s, InStrRev(s, "\") + 1)
	Next
Else
	oleReference = doc.ReferencedOLEFileDescriptors _
			.Add(selectedFile,OLEDocumentTypeEnum.kOLEDocumentLinkObject)
	oleReference.BrowserVisible = True
	oleReference.Visible = False
	oleReference.DisplayName = Mid$(selectedFile, InStrRev(selectedFile, "\") + 1)
End If

The following figures illustrate the difference in results: 

Without qualifiersWith qualifier

 

cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network