VBA SOLDIWORKS PackAndGo save modified assembly

Viewed 27

I've run into a problem while trying to automate SOLIDWORKS API VBA PackAndGo. The order of action I take are:

  1. Programmatically open an assembly
  2. Programmatically modify this assembly and it's components while renaming the modified components
  3. Programmatically engage pack and go

The unexpected problem is that the exported components have a correct / changed filename (as expected and as intended) but the actual models are the original none modified ones. This is something that I've only come across while trying to programmatically engage PackAndGo. When I do this routine manually from this modified assembly - the models that get renamed and exported are the actual new / modified ones.

My question is: "Why does this happen and how do I make it export teh models from active model?"

The code without the renaming routine etc. that I have written is:

Sub PackAndGo ()

'Set variables
Set swPackAndGo = swRootAssembly.Extension.GetPackAndGo

'Pack And Go
With swPackAndGo
    .IncludeDrawings = True
    .SetSaveToName True, OutputDirectory
    .GetDocumentNames DocumentNamesArray
    .GetDocumentSaveToNames DocumentSaveToNamesArray, 0
    
'Here I do the renaming of components in DocumentSaveToNamesArray
    
    .SetDocumentSaveToNames DocumentSaveToNamesArray
    
    .FlattenToSingleFolder = True
End With

'Pack and go
swRootAssembly.Extension.SavePackAndGo swPackAndGo

End Sub

Maybe I'm missing some additional method or function to make it copy the opened / active assembly components, rather than ones from the hard drive which are in fact the same models, but are not modified or altered in any way.

A simple example would be that I programmatically open a brick that's 20mm long and then programmatically change it's length to 50mm. Now I expect packandgo to save / export this 50mm long one but what it in fact does when run programmatically is export the same 20mm long brick, but with a different filename (again, different filename is what is expected)

0 Answers
Related