ilogic remove unresolved OLE links

ilogic remove unresolved OLE links

louis.seguin
Explorer Explorer
2,160 Views
3 Replies
Message 1 of 4

ilogic remove unresolved OLE links

louis.seguin
Explorer
Explorer

I have had trouble finding code that removes only unresolved OLE links on any inventor document. finally got one to work. thought i'd share.

coded on Ilogic Inventor 2014. I'm not a professional coder, feel free to correct syntax

 

SyntaxEditor Code Snippet

ThisApplication.SilentOperation = True 
 
 Dim oPartDoc As Document = ThisDoc.Document
 Dim bSaveDoc As Boolean = False
 Dim oRefOleFileDesc As ReferencedOLEFileDescriptor 
 
 If oPartDoc.ReferencedOLEFileDescriptors.Count > 0 Then 
     For Each oRefOleFileDesc In oPartDoc.ReferencedOLEFileDescriptors 
          'Debug.Print oRefOleFileDesc.ReferenceStatus 
          
          If oRefOleFileDesc.ReferenceStatus() = 49668 Then 
         

          '49668 = kMissingReferencE
             'Debug.Print (oRefOleFileDesc.DisplayName) 
              oRefOleFileDesc.Delete 
              oPartDoc.Dirty = True 
              bSaveDoc = True 
          End If 
        Next oRefOleFileDesc 
      
      If bSaveDoc = True Then 
          oPartDoc.Save 
          bSaveDoc = False 
      End If 
  End If 
' Be sure to set this back to False 
 ThisApplication.SilentOperation = False 

 

 

  

Accepted solutions (1)
2,161 Views
3 Replies
Replies (3)
Message 2 of 4

MechMachineMan
Advisor
Advisor
Accepted solution

Here's an alternative that just opens the files with broken links, and allows the user to delete or resolve manually.

 

The intent is to open a top level file, skip all unresolved links, then run this. Works good for FEA files.

 

Sub Main()
	Dim oDoc As Document = ThisApplication.ActiveDocument
	
	For Each oOLEFileRef In oDoc.ReferencedOLEFileDescriptors
		oOLEFileRef.BrowserVisible = True
	Next
	
	For Each oSubDoc As Document In oDoc.AllReferencedDocuments
		If oSubDoc.ReferencedOLEFileDescriptors.Count > 0
			OpenAndMakeOLEVisible(oSubDoc)
		End If
	Next
	
	MsgBox("Rule Complete!",,"iLogic")
End Sub

Sub OpenAndMakeOLEVisible(oDoc As Document)

'This boolean can be changed in case you want all files with OLE refs open. Dim oOpenOnlyMissing As Boolean = True
oVisiDoc = ThisApplication.Documents.Open(oDoc.FullFileName,False) For Each oOLEFileRef In oVisiDoc.ReferencedOLEFileDescriptors oOLEFileRef.BrowserVisible = True If oOLEFileRef.ReferenceStatus <> ReferenceStatusEnum.kMissingReference And oOpenOnlyMissing = True oVisiDoc.ReleaseReference Else ThisApplication.Documents.Open(oVisiDoc.FullFileName,True) End If Next End Sub

 

 

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 3 of 4

fce
Enthusiast
Enthusiast

Hello there,

it is a really helpful iLogic.
How would you delete the unresolved OLEs links?

Greetings,
Francisco

0 Likes
Message 4 of 4

dusan.naus.trz
Advisor
Advisor
0 Likes