External References and Copying Models
External References and Copying Models
(OP)
We have an API that opens a model (Assembly1.SLDASM) and copies it with it's dependents(part1.sldprt, part2.sldprt)to a different directory. When I re-run the API to copy the model Assembly2.SLDASM with it's dependents (part1.sldprt, part2.sldprt), these parts will be referencing Assembly1.SLDASM. Can anyone shed some light on this issue?
By the way, in between these copies we are CLOSING Solidworks! It seems as though Solidworks keeps parts with the same name in memory even after closing and rebooting. Has anyone had a similar issue?
By the way, in between these copies we are CLOSING Solidworks! It seems as though Solidworks keeps parts with the same name in memory even after closing and rebooting. Has anyone had a similar issue?






RE: External References and Copying Models
RE: External References and Copying Models
...It gets a little time consuming to try and strip it down to a macro.
RE: External References and Copying Models
Dim DocList As Object = SW.GetDocumentDependencies2(SourceFile, True, True, False)
If Not DocList Is Nothing Then
Dim SourceArray As String() = DirectCast(DocList, String())
Dim SourceCount As Integer = SourceArray.Length \ 2
Dim SourceFiles(SourceCount - 1) As String
Dim TargetFiles(SourceCount - 1) As String
For FileIndex As Integer = 0 To SourceCount - 1
Dim CurrentFile As String = SourceArray(1 + 2 * FileIndex)
SourceFiles(FileIndex) = CurrentFile
TargetFiles(FileIndex) = Path.Combine(TargetDirectory, Path.GetFileName(CurrentFile))
Next FileIndex
SldWorks.CopyDocument(SourceFile, TargetFile, SourceFiles, TargetFiles, CopyOptions)
RE: External References and Copying Models
If you launch Solidworks and then close it inbetween copying the assemblies, it seems to clear out the memory and the references are OK.
Why would Solidworks have anything in memory after it's closed!?
RE: External References and Copying Models
Since SolidWorks will search several locations for files, it probably maintians a list of where it has found a file. Since the old and new parts share the same name, it is probably opening the old part, with the old references, from the old directory.
Eric
RE: External References and Copying Models