Using iLogic to export parts list to excel

Using iLogic to export parts list to excel

Anonymous
Not applicable
1,323 Views
2 Replies
Message 1 of 3

Using iLogic to export parts list to excel

Anonymous
Not applicable

Hi,

 

i would like to export iProperties to excel and have some problems.

My intention is to have one iLogic Code that collects certain Properties of the assembly with all its sub-assemblies and all parts. My code (just a part of the data collecting):

 

Dim oAsmDoc As AssemblyDocument = TryCast(ThisApplication.ActiveDocument,AssemblyDocument)
If oAsmDoc Is Nothing Then
    MessageBox.Show("Activate assembly document first", "iLogic",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Exit Sub
End If

Dim Data(40) As String    	'string array for properties   
Dim row As Integer    		'start data row
Dim oPropSet As PropertySet
Dim oProp As Inventor.Property   

Dim empty1(500) As String
	
For Each oDoc As Inventor.Document In oAsmDoc.AllReferencedDocuments

	oPropSet = oDoc.PropertySets.Item("Design Tracking Properties")
    oProp = oPropSet.Item("Part Number")	'= Projekt/Status > Bauteilnummer
    Data(0) = oProp.Value
	
	oPropSet = oDoc.PropertySets.Item("Design Tracking Properties")
    oProp = oPropSet.Item("Description")	'= Projekt > Bezeichnung
    Data(1) = oProp.Value

 	Data(2) = iProperties.Material

 	'oPropSet = oDoc.PropertySets.Item("Inventor User Defined Properties")
    'oProp = oPropSet.Item("Material")	'= Projekt > Bezeichnung
    'Data(3) = oProp.Value 

	MessageBox.Show(Data(2), "iLogic",MessageBoxButtons.OK,MessageBoxIcon.Information)
	row = 12+CInt(Data(12))

Next

 

It works, but Data(2) only collects the Material of the assembly where i start my iLogic Code.

If i try the commented code to get Data(3), the first Data sets are correct but then i get an error message:

Unbekannter Fehler (Ausnahme von HRESULT: 0x80004005 (E_FAIL))

 

In some parts there are no user defined properties (purchased parts), but i want the Code to run nevertheless.

 

Can anyone tell me how to get a loop running with different kinds of iProperties to export, regardless of whether there is a value entered or not?

 

Greetings

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

WCrihfield
Mentor
Mentor

Maybe you can use a simple check like this for most properties:

If oProp.Value <> vbNullString Then
    Data(0) = oProp.Value
End If

 But since the Value of an iProperty is defined as an Object, instead of a specific data type, it's likely not going to universally work.  Not all iProperties return String type data as its value.

Also, an assembly doesn't really have a 'material'.  That info is within the parts only.  Although there is still a property called "Material" within the "Design Tracking Properties" set (Item 10).  If you need to retrieve something to put in that data slot for an assembly, I would suggest you retrieve it from that other property instead of from iProperties.Material.

 

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

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

Thanks for the answer, i tried it but i still get an error message.

I found another way with Try-Catch:

 

oPropSet = oDoc.PropertySets.Item("Inventor User Defined Properties")
Try
oProp = oPropSet.Item("Material")	'= Benutzerdefiniert > Material
Data(3) = oProp.Value
Catch
End Try

 

0 Likes