Ilogic delete unreferenced XREF

Ilogic delete unreferenced XREF

Kassenbouw
Enthusiast Enthusiast
579 Views
6 Replies
Message 1 of 7

Ilogic delete unreferenced XREF

Kassenbouw
Enthusiast
Enthusiast

Hi,

 

Does someone have a Ilogic code for deleting all unreferenced xrefs in Inventor?

 

Deleting this in Autocad is no option for me and the xref do not show up at 'Document Links and Embeddings' 

 

Kassenbouw_0-1636023257082.png

 

Thanks!

0 Likes
580 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor

I know that that 'links' dialog doesn't show every possible reference, because it usually doesn't contain anything when in a drawing or assembly which has references to other model documents.  However, if something is truly 'unreferenced' I'm not sure how you would break or delete that reference.  There are several possible 'types' of references though, and many possible types of objects at the ends of those references.

Here is just one example iLogic rule you can play around with that dabbles with one main possible type of references (OLE).

Dim oDoc As Document = ThisApplication.ActiveDocument
oCount = oDoc.ReferencedOLEFileDescriptors.Count
If oCount = 0 Then
	MsgBox("There are no OLE References.", vbInformation, "iLogic")
	Exit Sub
End If
For Each oRefOLEFD As ReferencedOLEFileDescriptor In oDoc.ReferencedOLEFileDescriptors
	oVis = oRefOLEFD.BrowserVisible
	oDName = oRefOLEFD.DisplayName
	oEmbedded = IsNothing(oRefOLEFD.FileDescriptor)
	oFFN = oRefOLEFD.FullFileName
	If oFFN Is vbNullString Then oFFN = ""
	oLKFileTime = oRefOLEFD.LastKnownFileTime
	If IsNothing(oLKFileTime) Then oLKFileTime = ""
	oLogName = oRefOLEFD.LogicalName
	oDType = oRefOLEFD.OLEDocumentType
	oRefStatus = oRefOLEFD.ReferenceStatus
	Dim oData As String = String.Empty
	oData = "DisplayName = " & oDName & vbCrLf & _
	"FullFileName (Empty If Embedded) = " & oFFN & vbCrLf & _
	"OLEDocumentType = " & oDType.ToString & vbCrLf & _
	"ReferenceStatus = " & oRefStatus.ToString & vbCrLf & _
	"Visible in Browser (if True, seen under 3rdParty folder) = " & oVis & vbCrLf & _
	"LogicalName = " & oLogName & vbCrLf & vbCrLf & _
	"Do you want to delete this ReferencedOLEFileDescriptor?"
	oAns = MsgBox(oData, vbYesNo + vbQuestion, "iLogic")
	If oAns = No Then
		Continue For
	ElseIf oAns = vbYes Then
		Try
			oRefOLEFD.Delete
		Catch oEx As Exception
			MsgBox("Failed to delete it." & vbCrLf & _
			oEx.Message & vbCrLf & oEx.StackTrace, vbExclamation, "iLogic")
			Continue For
		End Try
	End If
Next

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡 or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 7

Kassenbouw
Enthusiast
Enthusiast

Hi WCrihfield,

 

Thanks for the reply. 

When I run your rule i'm getting the message 'There are no OLE References' and nothing else happens. 

I know in autocad there is the possibility to detach files at the External References screen. 

 

I can't check-in the file as long as I do not remove the xref from the autocad drawing. 

 

Thanks

0 Likes
Message 4 of 7

WCrihfield
Mentor
Mentor

I found this older forum thread that sounds the same as this one, and it has an accepted solution.  Although the solution is using VBA instead of iLogic.  It may still be possible by iLogic, but you would most likely just have to include special lines in the 'header' of the rule to reference the proper AutoCAD object library similar to what was used through the References dialog in the VBA user interface.

Here is the link to that other post:

https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/how-to-delete-non-existing-reference-in... 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 7

Kassenbouw
Enthusiast
Enthusiast

I did found this thread (and some other) to but this code does not work for me. I'm using ilogic, not VB. 

When I remove 'Set' and run this I'm getting a error 'the type AcadDatabase is not defined'.

 

Do I need to place every XREF name seperate at the 'acadImageDict.Remove' line?

 

0 Likes
Message 6 of 7

WCrihfield
Mentor
Mentor

Unfortunately, I don't have those answers because I have never needed to try this before from iLogic.  I assumed that we would be able to add a 'AddReference' line an an 'Imports' line in the header of the iLogic rule, which point to the AutoCAD Object Library, then that would allow iLogic to recognize all those AutoCAD only objects, and allow us to work with them.  But I don't know what to put into those reference/import lines yet.  I opened my VBA main project, clicked on Tools tab > References..., which opens the References dialog box for the project in VBA.  Then I selected the one for the AutoCAD 20XX Type Library, and looked at its file location, which for me was "C:\Program Files\Common Files\Autodesk Shared\acax24enu.tlb".

WCrihfield_1-1636039925398.png

But that is a ".tlb" file instead of a ".dll" file, so iLogic doesn't seem to like it and tries to add the ".dll" onto the end of the file's name.  There are several other AutoCAD related references in the list too, but I think they are all ".tlb" type files.  If this is possible to do through iLogic (which uses vb.net), then maybe one of the Autodesk developers (or folks in the Autodesk Developers Network) may know the proper references to use for this task.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 7

Kassenbouw
Enthusiast
Enthusiast

Does anyone know how to solve this problem? I'm still running in to it when adding a ACAD dwg in Inventor. 

0 Likes