Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Derived Parts: Detect broken links with iLogic

fabimann
Contributor

Derived Parts: Detect broken links with iLogic

fabimann
Contributor
Contributor

Hi everyone,

I'm currently checking assemblies we recieved from a supplier. First I rebuild all parts through the manage tab of the assembly. Some errors where found this way but I noticed that broken links of derived parts are not detected by this method.

 

As the assembly contains quite a few subassemblys I'd like to ask for your help regarding a iLogic script which is able to detect derived parts with a broken link. These would preferably be listed in an Excel file.

 

Thank you in advance.

Best regards

Fabian

0 Likes
Reply
Accepted solutions (1)
389 Views
2 Replies
Replies (2)

JelteDeJong
Mentor
Mentor
Accepted solution

you can try this:

Dim doc As AssemblyDocument = ThisDoc.Document
Dim partDefs = doc.AllReferencedDocuments.Cast(Of Document).
    Where(Function(refDoc) refDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject).
    Where(Function(refDoc) refDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Count <> 0).
    Where(Function(refDoc) refDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Item(1).LinkedToFile <> True).
    ToList()

For Each refDoc As PartDocument In partDefs
    MsgBox(refDoc.DisplayName)
Next

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

fabimann
Contributor
Contributor

Hello Jelte,

thank you very much for your help, the code works flawless. Below, please find some bits I added to export the results to Excel.

 

Could you please help me again to also export the name of the missing component to the same Excel table? Unfortunately, I was not able to figure that out by myself.

 

Thanks again, much appreciated.

Best regards

Fabian

 

 

'Variablen
Dim RefPartList As New ArrayList()
Dim XLSXfolder, XLSXfileName, XLSXfile, XLSXtable As String
Dim XLSXrowBegin, XLSXrow As Integer

'Komponenten mit defekter Ableitung finden
Dim doc As AssemblyDocument = ThisDoc.Document
Dim partDefs = doc.AllReferencedDocuments.Cast(Of Document).
    Where(Function(refDoc) refDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject).
    Where(Function(refDoc) refDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Count <> 0).
    Where(Function(refDoc) refDoc.ComponentDefinition.ReferenceComponents.DerivedPartComponents.Item(1).LinkedToFile <> True).
    ToList()

For Each refDoc As PartDocument In partDefs
    RefPartList.Add(refDoc)	
Next

'Excel Export
XLSXfolder = "C:\Inventor-Zusammenfassungen\"
XLSXfileName = "test.xlsx"
XLSXfile = XLSXfolder & XLSXfileName
XLSXtable = "Tabelle1"

'Startzeile in Excel-Arbeitsblatt
XLSXrowBegin = 1
XLSXrow = XLSXrowBegin + 1

GoExcel.CellValue(XLSXfile, XLSXtable, "A" & XLSXrowBegin) = "Ableitung mit fehlender Referenz"

'Komponente mit defekter Ableitung
XLSXrow = XLSXrowBegin + 1
For Each refDoc In RefPartList
	CellFileName = "A" & XLSXrow
	GoExcel.CellValue(XLSXfile, XLSXtable, CellFileName) = refDoc.DisplayName
	XLSXrow = XLSXrow + 1
Next

GoExcel.Save

MessageBox.Show("Fertig", ":-)", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)

 

 

 

0 Likes