Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to remove ole links

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
GosponZ
3038 Views, 4 Replies

how to remove ole links

I do have code this code to remove ole links but it works on part level.

1. Is it possible to run this code from assembly and remove ole links from each part.

Some images with no reason knowing to me att. to each part in my assembly and can't check in vault. Shouldn't be tool for easy removal, and not to go part by part waste a lot time for nothing.

2. What make this situation?

 

Please experts I need help ASAP. This happened and it just pain.

 

Thank you All.

 

4 REPLIES 4
Message 2 of 5
MechMachineMan
in reply to: GosponZ

The following code makes the OLE links visible in the browser, so that you can easily delete the through the UI.

 

Sub Main()
	Dim oDoc As Document
	oDoc = ThisApplication.ActiveDocument
	
	If oDoc.ReferencedOLEFileDescriptors.Count > 0
		For Each oOLEFileRef In oDoc.ReferencedOLEFileDescriptors
			oOLEFileRef.BrowserVisible = True
		Next
	End If
	
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 5
GosponZ
in reply to: MechMachineMan

Can this code be adjusted to run from assembly?

Public Sub DeleteOLEReference()
    Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument

    If oDoc.ReferencedOLEFileDescriptors.Count = 0 Then
        MsgBox "There aren't any OLE references in this document."
        Exit Sub
    End If

    Dim aOLERefs() As ReferencedOLEFileDescriptor
    ReDim aOLERefs(oDoc.ReferencedOLEFileDescriptors.Count - 1)

    Dim iRefCount As Integer
    iRefCount = oDoc.ReferencedOLEFileDescriptors.Count
    Dim i As Integer
    For i = 1 To iRefCount
        Set aOLERefs(i - 1) = oDoc.ReferencedOLEFileDescriptors.Item(i)
    Next

    For i = 1 To iRefCount
        If MsgBox("Delete """ & aOLERefs(i - 1).FullFileName & """?", vbQuestion + vbYesNo) = vbYes Then
            aOLERefs(i - 1).Delete
        End If
    Next
End Sub

Message 4 of 5
MechMachineMan
in reply to: GosponZ

1. Please properly nest code and use the code wrapper, so it's easier to read and copy.

 

2. That code works of the active document as it is, so it works on assembly, parts, drawings. If by "work from assembly" you mean have it traverse through all of the parts and sub-assemblies of that main assembly, then yes, this is also possible as well.

 

 

Sub Main()
    Dim oDoc As Document

    'vba:
    Set oDoc = ThisApplication.ActiveDocument

    'vb.net:
    'oDoc = ThisDoc.Document

    Dim oLog As String

    For Each oSubDoc in oDoc.AllReferencedDocuments
        If oSubDoc.IsModifiable = True Then
            Call RemoveOLEsFromDoc(oSubDoc, oLog)
        End if
     Next

    Call MsgBox("Rule Complete!" & vblf & vblf & _
                  "OLEs Removed From: " & vblf & oLog)
End Sub


Sub RemoveOLEsFromDoc(ByVal oDoc As Document, ByRef oLogStr As String)
	
	If oDoc.ReferencedOLEFileDescriptors.Count > 0
		For Each oOLEFileRef In oDoc.ReferencedOLEFileDescriptors
			'oOLEFileRef.BrowserVisible = True
                         oOLEFileRef.Delete
		Next
                oLogStr = oLogStr & oDoc.DisplayName
	End If
	
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 5 of 5
GosponZ
in reply to: MechMachineMan

Cool thanks a lot. I run in assembly and remove all of them.

Thanks again

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report