iLogic assembly export (iProperty) help

iLogic assembly export (iProperty) help

k.grigoriou
Enthusiast Enthusiast
128 Views
2 Replies
Message 1 of 3

iLogic assembly export (iProperty) help

k.grigoriou
Enthusiast
Enthusiast

I have an assembly, and I want to use iLogic to collect data from all subassemblies:

Project > Description (iProperty)

Physical > Mass

and export these values into an Excel file.

I’ve tried several different methods, but none of them have given me correct results so far.

Could someone guide me on how to achieve this?

0 Likes
Accepted solutions (1)
129 Views
2 Replies
Replies (2)
Message 2 of 3

Andrii_Humeniuk
Advisor
Advisor
Accepted solution

Hi @k.grigoriou . The following iLogic code creates an Excel file with the assembly name in the same folder. Column A records the Description properties of all subassemblies, and column B records the masses of all subassemblies.

Imports Microsoft.Office.Interop
AddReference "Microsoft.Office.Interop.Excel.dll"
Public Sub Main()
	Dim oInvApp As Inventor.Application = ThisApplication
	Dim oADoc As AssemblyDocument = TryCast(oInvApp.ActiveDocument, AssemblyDocument)
	If oADoc Is Nothing Then Exit Sub
	Dim oOccs As ComponentOccurrences = oADoc.ComponentDefinition.Occurrences	
	Dim oADocs As IEnumerable(Of AssemblyDocument) =
				 From oRefDoc In oADoc.AllReferencedDocuments.OfType(Of AssemblyDocument)
				 Where (oOccs.AllReferencedOccurrences(oRefDoc).Count <> 0)
	If oADocs.Count = 0 Then Exit Sub
	Dim sPathExcel As String = oADoc.FullFileName.Replace(".iam", ".xlsx")
		
	Dim oExcel As New Microsoft.Office.Interop.Excel.ApplicationClass
	oExcel.DisplayAlerts = False
	oExcel.Visible = True
	
	Dim oWB As Excel.Workbook = oExcel.Workbooks.Add()
	Dim oWS As Excel.Worksheet = oWB.Worksheets(1)
	
	For i As Integer = 0 To oADocs.Count - 1
		Dim iRow As Integer = i + 1
		Dim oRefDoc As AssemblyDocument = oADocs(i)
		oWS.Range("A" & iRow).Value = oRefDoc.PropertySets("Design Tracking Properties")("Description").Value & ""
		oWS.Range("B" & iRow).Value = oRefDoc.ComponentDefinition.MassProperties.Mass
	Next

	oWB.SaveAs(sPathExcel)
	oWS = Nothing
	oWB = Nothing
	oExcel = Nothing
End Sub

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 3 of 3

k.grigoriou
Enthusiast
Enthusiast

@Andrii_Humeniuk Thank you very much, that was exactly what I wanted to do.

0 Likes