×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

External References and Copying Models

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?

RE: External References and Copying Models

If you can post your code it might help.  You say the parts are still referencing Assembly1.  Do the parts have in-context references?

RE: External References and Copying Models

(OP)
The original parts have in-context references to the assembly.  The copied parts have out-of-context references to the original assembly.

...It gets a little time consuming to try and strip it down to a macro.

RE: External References and Copying Models

(OP)
Essentially, the code in Visual Studio is:

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

(OP)
Just found a workaround for this.  Wondering if anyone can explain why this works:

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

Just a guess, but here goes.

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

(OP)
I think it's doing something similar to that too.  Anyone know of a way to stop Solidworks from searching for these file locations?  Is there a temporary directory to clean out?  An option I can't find?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources