Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing BOM from .SLDASM into Excel

Status
Not open for further replies.

farful

Mechanical
Mar 27, 2007
6
Summary: I wish to automatically obtain the Bill of Materials (BOM) from a SolidWorks assembly file (.SLDASM) and import it into Excel.


I'm somewhat familiar with VBA. I have an Excel file with a list of file location and file names. From here I want to create a connection to SolidWorks (via ADO/DAO? not sure how to do this) and extract the BOM information from the assembly and import it into Excel. There would be no need to physically open up the assembly, just create the connection and export the BOM information.

Thanks in advance!
 
Replies continue below

Recommended for you

this may help you get started.
Lenny's AssemblyBOM macro thread559-158093

[cheers]
SW07-SP3
 
There would be no need to physically open up the assembly, just create the connection and export the BOM information.

By this, do you mean that you don't want to have to load the assembly into ram at all, or do you mean that you just don't want to have it come up on the screen? I don't think BOM information is available without opening the assembly because the BOM is built dynamically from the assembly.

ADO: ActiveX Data Objects
DAO: Data Access Objects

Neither of these will give you access to information in a SolidWorks file. Only SolidWorks (or to a limited extent, SolidWorks Explorer) can access data in a SolidWorks file. It would be possible to automate SolidWorks using COM to open the assembly, traverse it, and build your own BOM from that data. However, unless you've seriously understated your familiarity with VBA (and the SolidWorks API in particular), I would say that what you've stated that you want to do will require a lot more assistance than it's possible to give in a web forum.

 
Wow thanks, this definitely looks very useful.

Unfortunately I guess my VBA knowledge really isn't that great... This macro requires that I run it from SolidWorks. Anyone by any chance know how to get started from Excel?
 
Ah, thanks for the info handleman. I'll rethink this some more.
 
Okay, I guess this is what I have in mind:

Assuming I have a list of Path + File names of assembly drawings in Column A in an Excel file:

Set swApp = CreateObject("SldWorks.Application")
For i = 1 to Range("A65536").End(xlUp).Row
PathName = Cells(i, 1).Value
Set swPart = swApp.OpenDoc(PathName, swDocDrawing)

'Somehow extract BOM information and export to Excel.
Next i

Can be changed to open Assembly instead of Drawings if that's easier. I'm not sure how BOM information is stored exactly
 
BOM is not stored in an assembly (SLDASM). You will have to traverse the assembly and extract the properties from each component, one by one. Look again at the answer you got from CBL.
 
Ah, stupid question........why not dump the assembly into a drawing and insert an Excel BOM from there. You can then save it outside SW and then add the doc in design binder in the assembly.

Macduff [spin]
Colin Fitzpatrick
Mechanical Design Engineer
Solidworks 2007 SP 2.2
Dell 390 XP Pro SP 2
nVida Quadro FX 3450/4000



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor