12 Replies Latest reply on Oct 13, 2017 10:01 AM by Greg Sims

    Pack & Go with External Global Variables

    Greg Sims

      Hi Everyone,

      I'm having an issue when I pack & go parent assemblies when the subassemblies each has its own externally linked .txt equations file. My basic file structure is like this:

       

      • 12345_PARENT.SLDASM
        • 12345A_CHILD.SLDASM
          • 12345A_EQUATIONS.TXT
          • 12345A01.SLDPRT
            • 12345A_EQUATIONS.TXT
          • 12345A02.SLDPRT
            • 12345A_EQUATIONS.TXT
          • 12345A03.SLDPRT
            • 12345A_EQUATIONS.TXT
        • 12345B_CHILD.SLDASM
          • 12345B_EQUATIONS.TXT
          • 12345B01.SLDPRT
          • 12345B_EQUATIONS.TXT
        • 12345B02.SLDPRT
          • 12345B_EQUATIONS.TXT
        • 12345B03.SLDPRT
          • 12345B_EQUATIONS.TXT

       

      If I pack & go one of the child assemblies to create a new one (in the above example, I might P&G 12345B_CHILD.SLDASM to create 12345C_CHILD.SLDASM), it works just fine. It creates the new child assembly, all the new parts, and the new .txt file, and everything is linked correctly. However, if I P&G the PARENT assembly somewhere else, then every single subassembly and every single part breaks its link to its corresponding .TXT file, and instead links to the very last .TXT file in the list. In the above example, if I were to P&G the parent assembly, then 12345A_CHILD.SLDASM and all of its parts would be linked to 12345B_EQUATIONS.TXT and therefore it's now broken. This is extremely problematic with huge assemblies with hundreds of parts. In the project I'm working on right now, this has happened with all 31 subassemblies and all 288 of its parts. Everything got linked to the last assembly in the list, and is therefore broken and I have to go through the tedious process of correcting it. Costing me about half a day. The misdirected link occurs not only in the newly packed & go assembly, but also in the original assembly, so there's no unbroken model to revert back to.

       

      Does anyone have any experience with this, or how to correct it? Our company has multiple divisions and I need to be able to P&G this model to one of our other divisions ASAP.

       

      Thanks!

      -Greg

        • Re: Pack & Go with External Global Variables
          Vladimir Urazhdin

          I prefer instead of .txt linked files use build in equations. Pack & go works fine and no worry about broken external links at all.

          • Re: Pack & Go with External Global Variables
            John Stoltzfus

            This might be a reference for you..

             

            https://forum.solidworks.com/message/308961#comment-308961

             

            How are you saving your pack & go, in the same directory?  Same folder?

            • Re: Pack & Go with External Global Variables
              Greg Sims

              Update: If, during the P&G process, I use select/replace to rename all the components & .txt files, then the links DO NOT break, and they're all still linked to the correct .txt files. Which is awesome! However, the parts and assemblies are all still linked to the ORIGINAL .txt files. In other words, pack & go makes copies of the .txt files and puts them where I tell them to go, but it doesn't link the parts & assemblies to the new copies. So the problem still isn't really solved.

                • Re: Pack & Go with External Global Variables
                  Elmar Klammer

                  Hi Greg,

                   

                  I don't know why P&G does it. With SW you need to think flexible. Maybe the code below makes it a bit easier. A second step is required but beats manual labor.

                  You got the copy and know the new file names.

                  Below is code that will read the file path of the linked equation. Modify it and relink to your new txt files.

                   

                   

                  Dim swApp As SldWorks.SldWorks

                  Dim swModel As SldWorks.ModelDoc2

                  Dim swEqnMgr As SldWorks.EquationMgr

                   

                  Sub main()

                   

                      Set swApp = Application.SldWorks

                   

                      Set swModel = swApp.ActiveDoc

                   

                      Set swEqnMgr = swModel.GetEquationMgr
                     
                  '----------------get info
                  ' Get Equation manager object
                      Set swEqnMgr = swModel.GetEquationMgr
                      ' List the equations, get whether they're linked
                      ' to files, make sure any equations are up to date,
                      ' and get the paths where they're stored
                      nCount = swEqnMgr.GetCount
                      For I = 0 To nCount - 1
                          Debug.Print "  Equation #" & I & " = " & swEqnMgr.Equation(I)
                          eqnLinked = swEqnMgr.LinkToFile
                          Debug.Print "  Equation linked to file? " & eqnLinked
                          If eqnLinked Then
                              'Make sure equations are up to date
                               swEqnMgr.UpdateValuesFromExternalEquationFile

                              'Get path and name of linked equation file
                              Debug.Print "  Path and file name of linked equation: " & swEqnMgr.FilePath
                          End If
                      Next I

                  '------------------------- relink path

                   

                      swEqnMgr.LinkToFile = True

                      swEqnMgr.FilePath = "I:\$Projects\_PDF\equations - Copy.txt"  'enter new path

                   

                  End Sub

                • Re: Pack & Go with External Global Variables
                  Greg Sims

                  Well, our Solidworks distributor found me a workaround:

                  1. Use Pack and Go to save a copy of the assembly and all components in a new folder, keeping the all the original names, unselecting the checkbox beside all the txt file references so they don’t get copied.
                  2. After SolidWorks Pack and Go is complete, shut down all the files without saving any changes.
                  3. Use Windows Explorer to copy and paste all the reference text files into the new folder with the new copy of the assembly.
                  4. The next step is to make sure SolidWorks can’t see the original files either by temporarily renaming the folder the original text files reside in or maybe temporarily changing the mapping on the drive.
                  5. Open the top level assembly from the new folder. When SolidWorks doesn’t find the text files in the original location it will look in the folder with the assembly and load them from there. Verify a few of the files are loading the correct file.
                  6. Use CTRL+Q to fully rebuild and then Save. Once you rebuilt and saved it, the pointers will point to the files in the new folder for future opens.
                  7. Rename the original folder or remap.