Bill of materials in separate files

Bill of materials in separate files

farshidDWRFR
Enthusiast Enthusiast
444 Views
8 Replies
Message 1 of 9

Bill of materials in separate files

farshidDWRFR
Enthusiast
Enthusiast

Hi everyone.

 

I have an assembly composed of several components in 3 materials.

Does anyone know how to export BOM to 3 separate files based on materials using iLogic? In other words, I want to have one Excel file for components with Material 1, one for Material 2, and one for Materials 3.

 

Thanks in advance for your help

0 Likes
445 Views
8 Replies
Replies (8)
Message 2 of 9

A.Acheson
Mentor
Mentor

Here is a post that exports the bom line by line filtering by certain criteria as it goes. If you think that you would be able to modify it to search for the material this would be a good fit. Post the code here if you have trouble. 

https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/possible-to-export-a-particular-bom-for...


If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 9

farshidDWRFR
Enthusiast
Enthusiast

Hi A.Acheson,

 

Thanks for your reply.

This is not exactly what I need. What I am after is:

1. I need it to follow the Inventor BOM structure. I don't want to lose BOM columns such as Part Number, QTY, Thumbnail, etc.

2. I need the general Excel file created from BOM split and saved into multiple files based on an iProperty such as material. For example, instead of 1 file containing all wooden, steel, and Al parts, I want Inventor to create 1 file containing only wooden parts, 1 file containing only steel parts, and 1 file containing only Al parts.

 

Do you think you can help me with this?

Thanks

0 Likes
Message 4 of 9

A.Acheson
Mentor
Mentor

Probably the best solution I can think off is to export the complete bom to excel then just use the application to copy the rows containing your info to new workbooks. Basically exactly as you would do manually. 

Are you using any BOM export rule at the moment? If so please post as it would have all your settings.

 

Alternative is to export the BOM either manually or through ilogic.

Then as a separate operation create create a personal macro in excel vba to do this excel filtering.

 

Your task really is excel manipulation.. You could look up vba tutorials for excel if you want to have a go at it. While it can be done through inventor using vba/vb.net it is a little more difficult.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 9

farshidDWRFR
Enthusiast
Enthusiast

Thanks again for your response.

Doing the job manually or partially in Inventor and the rest in Excel is not ideal for me, because I need to use the approach I come up with in several similar files. So, I need to find an automatic solution.

Currently, I don't have a specific iLogic rule to post here, but I'm working on it.

Do you think it would be possible to exclude parts with specific iProperties from BOM? I am thinking of writing a snippet capable of exporting separate Excel files for every single iProperty value (let's say different materials) and excluding the irrelevant ones from each case, i.e not including materials 2 and 3 in the file created for material 1.

Thanks

0 Likes
Message 6 of 9

A.Acheson
Mentor
Mentor

Here is a rule that does something similar. The filter criteria will need to change but it is 75% there. 


https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/how-to-export-bom-with-purchased-normal...

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 7 of 9

farshidDWRFR
Enthusiast
Enthusiast

Yes, I agree. This may help, however, I need to manipulate it. 

I will let you know about the outcome.

Thanks

0 Likes
Message 8 of 9

farshidDWRFR
Enthusiast
Enthusiast

Hello again,

 

I managed to change the code according to my needs. It now creates 4 Excel files based on 4 custom features I have assigned to components. Thanks for your help.

I have now another question: I want the Excel files saved in a folder, but need the iLogic rule to scan the folder and delete all files in it before saving files (or overwrite the existing files, whatever is easier). Can you please help me with this?

 

Thanks very much

0 Likes
Message 9 of 9

A.Acheson
Mentor
Mentor
Imports System.Windows.Forms
Imports System.IO

'File Path Creation/Processing 'Note, the following line will cause an error if the document is not saved. Dim oExportPath As String = "C:\EXPORT INVENTOR\" Dim oExportName As String = oExportPath & "BOM unfiltered" 'without extension'get BOM Target folder path If Not System.IO.Directory.Exists(oExportPath) Then: System.IO.Directory.CreateDirectory(oExportPath): End If If Dir(oExportName & ".xlsx") <> "" Then 'Delete Excel File Kill (oExportName & ".xlsx") End If

 Try integrating this. It just checks if the path exist if it does deletes the field if not creates the directory

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes