7 Replies Latest reply on Aug 5, 2014 10:44 AM by Chris Iannone

    Updating Component Location

    Chris Iannone

      I had changed the way my file management system was set up which included moving every SolidWorks file to a new location.  Because of this, when I open assemblies, the components cannot be found.  I've created a macro that reads the names of the selected components and builds a string of the location of where the part has been moved to.  I use ReplaceComponents method which works 25% of the time.  My guess to why it doesnt work is because the components can't be replaced with ones that have the same name, but I'm not sure why it works some of the time.  Is there a better way of doing this?

        • Re: Updating Component Location
          Sean Phillips

          SolidWorks.Interop.sldworks

          DSldWorksEvents_PromptForMultipleFileNamesNotifyEventHandler Delegate (SolidWorks.Interop.sldworks)

           

          Generated when any dependent documents are missing from the file being opened.

           

          Public Delegate Function DSldWorksEvents_PromptForMultipleFileNamesNotifyEventHandler( _

             ByVal openOrSave As Integer, _

             ByRef suggestedFileNames As Object, _

             ByRef DocTypes As Object, _

             ByVal cause As Integer _

          ) As Integer

           

          Dim instance As New DSldWorksEvents_PromptForMultipleFileNamesNotifyEventHandler(AddressOf HandlerMethod)

           

          Parameters

          openOrSave
          • 0 = save
          • 1 = open
          suggestedFileNames
          Array of names of the missing SolidWorks documents
          DocTypes
          Types of missing SolidWorks documents as defined in swDocumentTypes_e
          cause
          Cause as defined in swPrompForFilenameCause_e


          1 person found this helpful
          • Re: Updating Component Location
            Andries Koorzen

            Hi Chris. Perhaps this fails because the files you're trying to replace is already open in SolidWorks, but just from a different location?

             

            Also -> on a side note: Why use a macro and not just update your search paths in SolidWorks with the macro? That way when the files are being searched for, it will be  found. Check out 'Search Routine' in the SolidWorks help files to help you use the search paths. If the files are in subfolders, you should have a fair amount of success.

            1 person found this helpful
              • Re: Updating Component Location
                Chris Iannone

                The files I'm trying to replace aren't open.  I can open a document that I know has parts that need to be updated as soon as I start up SolidWorks and it won't work, (sometimes).  The macro use to work well then recently it doesn't seem to work at all so there is something going on that I am unaware of.

                 

                As for the search paths, I have my files in their own individual folders; will the search paths work in this case? My parts are six digits and the folders are broken up in one hundred thousands, then thousands, then the individual parts.

                 

                100000

                     100000

                          100000

                          100001...

                     101000

                          101000

                          101001...

                 

                Would it be wise to remove them from their own folder and place them into larger directories, such as just one hundred thousands?

              • Re: Updating Component Location
                David Peer

                Enter the current components directory Paths in the list of referenced files tools --> options--> file locations.

                next time you open the assembly files will be found and after a save their new location will be remembered

                1 person found this helpful
                • Re: Updating Component Location
                  David Peer

                  another way is using the document manager . however you have to be proficient with solidworks api or you can damage the files

                  • Re: Updating Component Location
                    Chris Iannone

                    I ended up writing a macro to move all of my files out of their individual folders into #00000 folders and set up the search path to those 10 folders.  The missing components are found and it seems to work just fine.  Thanks everyone for the tips.