Can I reference a SW file without actually opening it in SW?

Good afternoon, all

 

I'm trying to set up a macro to programmatically determine USED ON and NEXT ASSEMBLY relations (I've asked Tech Support about this, and while there is a tool available, it's a for-purchase solution; hence, I need to build one :-))  I've worked out the logic in and Excel spreadsheet, and so now I'm looking to pull it all together.

 

swTableAnnotation.SaveAsText2 or something similar without going through the Open/Update/Resolve/Render steps on-screen in SW since I don't actually need them for what I'm doing>

 

https://r1132100503382-eu1-3dswym.3dexperience.3ds.com/home?content=swym:prd:R1132100503382:qnaquestion:PE9St1e9SuiXTFrJB6QrTg walks through an aspect of the solution, and John Sitek's (slightly edited to just focus on the BOM instead of also weldments and shown below) code works great.  I get a text file that's tab-delimited of the BOM for the drawing file that's open.

 

Now, that's nice and all, but it requires that I have the drawing file open, and is a step or three away from what I want.

 

Right now, I'm facing a few options:

  1. Use versions of this code and iteratively step through all the relevant drawings to form an overall reference map.
    1. Each file would reveal what BOM element I need
    2. Once I've rotated through all the drawings, I can invert that to get a list of all assemblies that contain a part/assembly (the USED ON" part)
    3. I can then rerun through all the drawings and add that information to the datacard properties
  2. Use my excel sheet that works all those relationships from an exported CSV of the Top-Level Indented BOM in the File Explorer view
    1. the output of that excel sheet is then referenced as we run through all the drawings and add the information to the datacards

 

1) puts everything in a singular fashion, but will take longer as I have to open all the drawings in SW, reference the information, and then close the drawings TWICE.  Not Terribly clean but workable

 

2) nigh-instantaneously creates the first half of the solution, but is a distinctly two-step process which opens more doors for the unfamiliar to mess things up...

 

So at long last, my question is: "Can I access the information via John's code without actually opening the file in SW"?  I'm fine "opening" it in the code, I just don't want to go through the whole updating/resolving/etc steps to result in a visible drawing before doing so.

Option Explicit

Sub Main()

Dim swApplication As SldWorks.SldWorks
Dim swDrawing As SldWorks.DrawingDoc
Dim swBOMFeature As SldWorks.BomFeature
Dim swTableAnnotation As SldWorks.TableAnnotation
Dim vbFeatures As Variant
Dim vbFeature As Variant
Dim vbSeparator As String

Set swApplication = Application.SldWorks
vbSeparator = vbTab

'If a drawing is not open...
If Not swApplication.ActiveDoc.GetType = swDocDRAWING Then
   MsgBox "Please open a drawing first.", vbOKOnly, "Drawing Macro"
   Exit Sub
End If


Set swDrawing = swApplication.ActiveDoc
vbFeatures = swDrawing.FeatureManager.GetFeatures(False)

'Loop features
For Each vbFeature In vbFeatures
   
   If vbFeature.GetTypeName2 = "BomFeat" Then
       Set swBOMFeature = vbFeature.GetSpecificFeature2
       Set swTableAnnotation = swBOMFeature.GetTableAnnotations(0)
       'Save BOM to CSV
       swTableAnnotation.SaveAsText2 Replace(swDrawing.GetPathName, ".SLDDRW", "-BOM.txt", 1, -1, vbTextCompare), vbSeparator, False
   End If
   
Next vbFeature

End Sub