Copy out entire iPart or iAssembly table to excel with ilogic

Copy out entire iPart or iAssembly table to excel with ilogic

danny.lewisA9QBW
Advocate Advocate
772 Views
6 Replies
Message 1 of 7

Copy out entire iPart or iAssembly table to excel with ilogic

danny.lewisA9QBW
Advocate
Advocate

I've got a a code that cycles through all each rows of an ipart and then writes all the values into a new excel file.... But there's got to be a way to copy/save out the excel version table that's available in iPart/iAssembly in the model.

 

Can someone help me out with this? 

0 Likes
Accepted solutions (1)
773 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor

Have you tried the iAssemblyFactory.Export Method yet?  Or the iPartFactory.Export method?

It does say that these methods were introduced in the 2021 release, so if you have an older version of Inventor, they may not be available to you yet.

 

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

danny.lewisA9QBW
Advocate
Advocate

I did not know about that... I kept getting hung up on the .ExcelWorkSheet part and tried in vain to make that work...

 

however, I'm trying this now and getting an error message; Any thoughts on where I'm screwing up?

 

 

Sub Main

Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
If oAsmDoc.ComponentDefinition.IsiAssemblyFactory = True Then

Dim oiAssyFactory As iAssemblyFactory = oAsmDoc.ComponentDefinition.iAssemblyFactory
oiAssyFactory.Export("C:\Vault\Testing\TEST4",74498)		'FileFormatEnum.kMicrosoftExcelFormat
End If

 

 

 error code 2.JPGerror code 1.JPG

0 Likes
Message 4 of 7

WCrihfield
Mentor
Mentor

1) I don't have Vault, so I don't know if trying to save a file into one of it's directories is allowed.  Those directories may be monitored/controlled by Vault, and may be read only unless written to through Vault, or they may be set-up similar to a Library (also sort of read only) or similar to the Content Center.

2) I don't have any iAssemblies to test the code on because we generally avoid using iAssemblies/iParts in favor of purely iLogic automated configuration scenarios and our own filing system situation.  But my first test would be to specify "FileFormatEnum.kMicrosoftExcelFormat" directly, instead of it's numerical Value within the Enum, since the input variable's type was specifically FileFormatEnum, and not Object, but I don't know if that will make any difference.  And since the help page doesn't inform us about which 'option' Names are available/recognized, and also doesn't inform us which Values would be available/recognized, for use within the 'Options' input variable (NameValueMap), we don't know if specifying something within that may help us out here either.

 

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

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 7

danny.lewisA9QBW
Advocate
Advocate

The help (iAssemblyFactory.Export Method ) is pretty thin for information... just says "FileName as String"... is that file path, does that include the extention...etc.

 

So far I've tried these (vault wasn't the issue... but I removed it anyway)... none of them work:

Sub Main


Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument

If oAsmDoc.ComponentDefinition.IsiAssemblyFactory = True Then

Dim oiAssyFactory As iAssemblyFactory = oAsmDoc.ComponentDefinition.iAssemblyFactory

'Dim Filename As String = "C:\Testing\TEST4.xlsx"
'Dim Filename As String = "TEST4.xlsx"
'Dim Filename As String = "C:\Testing\TEST4"
Dim Filename As String = "TEST4"

oiAssyFactory.Export(Filename, FileFormatEnum.kMicrosoftExcelFormat)		'74498	'FileFormatEnum.kMicrosoftExcelFormat

End If

 

0 Likes
Message 6 of 7

WCrihfield
Mentor
Mentor
Accepted solution

I just created a quickie simple iAssemblyFactory type assembly document, then did some trial/error testing on this, and got it to work for me.  It was the file name extension that was tripping us up.  We're both expecting it to be an ".xlsx", because that's what all the newer regular Excel documents put out, but it needed to be the old ".xls" file extension for me, for it to work, even though I'm using the 2019+ versions of MS Office & Excel.  Quirky.

My working code looks similar to your initial code, but just adds the ".xls" file extension.

Dim oADoc As AssemblyDocument = ThisDoc.Document
If oADoc.ComponentDefinition.IsiAssemblyFactory Then
	Dim oPath As String = "\\DIV29-FS-01\Shared\Engineering\SHARED\Tests\iAssemblyTableExported.xls"
	oADoc.ComponentDefinition.iAssemblyFactory.Export(oPath, FileFormatEnum.kMicrosoftExcelFormat)
End If

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 7 of 7

danny.lewisA9QBW
Advocate
Advocate

Hmmmm.... so got it working, but the path i used was the issue.... NO IDEA WHY!

 

error message 3.jpg

0 Likes