ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
CWCurtis Watson16/03/2015

Hey guys,

We've developed a system within our company's ERP system to interface with EPDM, load assemblies/parts into SolidWorks, find related drawings for all items in the BOM, find the related drawings and save them to PDF. This provides us up-to-date drawings for assemblies as the models are updated.

The system has been in production for almost a year now with great success. Recently we have started experiencing issues with very specific parts - maybe one or two of the thousands and thousands of models in the EPDM system. The issue is repeatable with the given part numbers.

Essentially the system operates as follows:

1) Part number passed in.

2) Look for .SLDASM, if not found then look for .SLDPRT, if not found then look for .SLDDRW - based on the part number passed in, we look for file matching that part number with different file types.

3) If a .SLDASM or .SLDPRT is found, find the .SLDDRW for that part and save it as PDF on network drive.

3a) For each item in the BOM (recursively),

3aa) Get file information, check if already open in SW; if not already open, open it in SW.

3ab) Find related drawing, open if not already open and save it as PDF on network drive.

Essentially the system is failing when about halfway through a part's BOM - the last log message our system wrote is "Checking if file is already open within SolidWorks...". After we write this line into the log, we execute the following line of code. Please note that we write a log message immediately after this API call - this API call is the cause of the thrown exception.

If solidWorks.GetOpenDocumentByName(file.Path) IsNot Nothing Then

    isFileOpen = True

End If

The 'solidWorks' variable is of type 'SolidWorks.Interop.sldworks.SldWorks' and through other logging, I have confirmed that the 'solidWorks' object is instantiated and that the 'file' variable is instantiated and that the 'file.Path' property is populated with a valid EPDM path.

The exception being encountered is as follows - note the first item in the StackTrace is a SolidWorks API method (it is thrown from within the API and not from within my code):

Exception encountered in EpdmService.GetBillOfMaterial().

Exception.Message='The remote procedure call failed. (Exception from HRESULT: 0x800706BE)',

Exception.StackTrace='

   at SolidWorks.Interop.sldworks.SldWorksClass.GetOpenDocumentByName(String DocumentName)

   at EpdmLibrary.EpdmManager.GetBillOfMaterial(EpdmFile file, Boolean generateDrawings, Int32 version, String configuration, Decimal quantityMultiplier, SldWorks& solidWorks, SalMessageCollection& messages, Boolean& wasExecutionSuccessful)

   at EpdmLibrary.EpdmManager.GetBillOfMaterial(EpdmFile file, Boolean generateDrawings, Int32 version, String configuration, Decimal quantityMultiplier, SldWorks& solidWorks, SalMessageCollection& messages, Boolean& wasExecutionSuccessful)

   at EpdmLibrary.EpdmManager.GetBillOfMaterial(EpdmFile file, String partConfiguration, Boolean generateDrawings, Decimal quantityMultiplier, SalMessageCollection& messages, Boolean& wasExecutionSuccessful)

   at EpdmService.EpdmServiceLibrary.EpdmService.GetBillOfMaterial(String partNumber, String partConfiguration, Decimal quantity, Boolean generateDrawings, ServiceExecutionConfiguration serviceConfiguration, SalMessageForWebServiceCollection& messages, Boolean& wasExecutionSuccessful)'.

Does anyone have some ideas as to what could be causing this? I've reviewed the event log on the server which hosts this system without finding anything further. Any ideas on how to debug what is going wrong in the API call or where I could look to find logs around what is going on?