Creating an Assembly BOM | SolidWorks API: Document Manager

Hello

I am in the process of creating a VB.net application to set up the exchange of data between SolidWorks and our ERP.

To do this, I use the SolidWorks Document Manager API, which allows you to access the information in the files without opening them in the application. More information: http://help.solidworks.com/2015/english/api/swdocmgrapi/GettingStarted-swdocmgrapi.html?id=c64a324db326402a84186311e072bc1c#Pg0

I can read, edit, and create custom properties.

I want to create assembly BOMs. To do this, I manage to extract a bill of materials if it already exists , then import it into Excel. Using the GetTableNames and GetTableCellText methods.

However, despite a lot of research, I can't manage to create a nomenclature.

Thank you in advance

2 Likes

Hello

Do you want to create a bill of materials in an assembly 3D without opening the file?

1 Like

Yes. A bit like SmartBom but at my modest level...

1 Like

I came across a post that doesn't give the solution, but I just saw that you already went there this morning ;-) I think the person who said it's possible, didn't know about Document Manager...

Looking for BOM on this page (which lists all the Document Manager commands a priori), there are only instructions like "access" or "get", but nothing to create, sorry:

http://help.solidworks.com/2015/english/api/swdocmgrapi/SolidWorks.Interop.swdocumentmgr~SolidWorks.Interop.swdocumentmgr_namespace.html?id=30a118bab16d4ebdb948d29c74dcfd9f#Pg0

Or by searching for TABLE and looking at the members on this page (expanding with the +), we find nothing either:

http://help.solidworks.com/2015/english/api/swdocmgrapi/SolidWorks.Interop.swdocumentmgr~SolidWorks.Interop.swdocumentmgr.ISwDMTable_members.html?id=b4f08e90682443dd91ef867afd8a2192#Pg0

A priori the link below is only useful when the file is opened, isn't it? I think that's what you're going to have to do.

http://help.solidworks.com/2015/English/api/sldworksapi/Insert_and_Show_BOM_Table_in_Assembly_Example_VBNET.htm

 

Or another capillotracted solution, is to go through all the SolidWorks tree to create your table and recreate it as a text file...

 

By the way, are you sure SmartBOM doesn't open the file?

 

Edit:

A response from someone who uses the Domcument Manager to confirm my words:

https://forum.solidworks.com/message/467937#467937

It goes through all the rooms well...

 

Edit 2: it can be dangerous to create the bill of materials without opening the file, because if one of the components has been modified (change of code, material, in a welded machine, etc.) without updating the assemblies that contain it, your bill of materials will be wrong!

 

Edit 3: a solution could be to include a bill of materials in the models of your assemblies, at least all the new assemblies created will not be a problem!

6 Likes

Thank you .PL For this answer.

I see that we have similar research methods. ;-)

Indeed, I hadn't tested SmartBom on large assemblies for a long time, I think he must open it...

So I'm going to try to do the same.

I come back here as soon as I succeed. :-)

1 Like

Good luck, because it's not an easy task.

Do you have a PDM to manage files? Because I don't proceed in the same way.

And did you see my edit 3 from the previous question?

Of course if I don't open my file the table may not be up to date.

In the code I will:

  1. Check if a table (from the script) is present without opening it.
  2. If so, I tell the user the date of the last registration to know if it is obsolete.
  3. If not, I open the file to update or create a table.

Have a nice day.

And do you have a PDM to manage files? Or is it just a slot on the server?

No, not PDM.

But we're working on it...

Ok, and you want to do your macro on all files? Or only the new ones?

FYI, I think you can use the background mode to not display the opening:

http://help.solidworks.com/2011/English/api/sldworksapi/Enable_Background_Processing_When_Opening_Drawing_Document_Example_VB.htm

 

Hello

This is an application Vb.net integrated into Excel like this: http://jfdeterme.developpez.com/tutoriels/dotnet/developper-add-in-pour-excel-2007-avec-visual-studio-2010/

See you.

Thanks to .PL,

Indeed after asking the APi support and on the SW forum.

It is necessary to open the files and then use the method: IModelDocExtension::InsertBomTable3

My App works! ;-)

Thank you.

 

 

1 Like