Try GetDependencies2 Method
You can apply your FileExists method to all the files to return bad filepaths or write false returns to a list.
I'm not sure how this works with configurations though.
value = instance.GetDependencies2(Traverseflag, Searchflag, AddReadOnlyInfo)
True to traverse down into all dependent files, false for only the highest level within the dependencies
True to use the search rules to find dependencies, false to look where the documents were last saved
True to show read-only information in the returned strings, false to not
Calling this method on a drawing document returns a list of all the parts and assemblies used in the drawing. If you set Traverseflag to True, then each of the parts within the assembly file is also returned in this array of strings.
Because a derived mirror part is generated from another part, the list of model dependencies returned by this method would include the original part used to generate the derived mirror part.
Library features are completely unassociated. They do not require the library nor do they update when changes are made to the library feature. Therefore, this method does not return library features.
If you use this method with an assembly that contains two documents, Part1 and SubAssem1, an example of what might be returned is:
[ "Part1", "C:\temp\Part1.SLDPRT", "SubAssem1", "c:\temp\SubAssem1.SLDASM" ]
If Traverseflag is set to True, then all the documents contained in SubAssem1.ASM are returned. Also, suppressed components are recognized and returned by this method as a dependent file.
If AddReadOnlyInfo is set to True, then a string of True or false is added to the list of strings. If Part1 is read-only, then the resulting set of strings would be:
[ "Part1", "C:\temp\Part1.SLDPRT", "True", "SubAssem1", "c:\temp\SubAssem1.SLDASM", "" ]
NOTE: For assemblies containing suppressed or lightweight components, file references (return value from this method) point to the as-saved component reference because the actual component has not been loaded into memory. Because the suppressed and lightweight components have not actually been loaded, the current search criteria has not been applied to update the file references. Setting Searchflag to True vs. false, causes this method to apply the current search criteria rules to locate the particular reference and may result in a different return value. Likewise, unsuppressing or resolving these components causes the current search criteria to be applied and updates the assembly's component references in memory, if necessary.
When calling this method with Seachflag set to True, you can explicitly set the search folders first. This is important because this method uses the current SOLIDWORKS directory as its second search criteria. Because the user may have interactively opened files from some random directory, you cannot be certain the current SOLIDWORKS directory is pointing to the desired location. You may want to consider setting the search folders to that of the document being used in this method.
deepfuly thanks. It works fine and much more performant as my solution!
I dont have to iterate through all configurations any more!
That was what I was looking for!
Greeting and have a nice day!
Hello guys, I am wondering if you would be willing to share your method (macro) of finding broken file references. I have been wanting to do this to our SolidWorks files for a little while now and I am not familiar with programming / api stuff. When I look at your conversation here, it looks like a foreign language to me.
I would greatly appreciate any assistance you would be willing to share. Thank you.
On a similar note, I am thinking about learning how to do the programming / api stuff, but do not know where to start. would you be willing to give pointers on how you guys learned this stuff? Did you go to school for it? Did you just take some classes? Etc.
You can find lots of examples just by searching for Solidworks api in google.
This link has two sets of example code, it's what I started with.
Get Active Document Dependencies (VBA)
Get Unopened Document Dependents (VBA)
i am not progamming a macro. I am programming a stand alone application with much more checks stuff in the code, so sharing would not be possible for me. But I can post you a snippet of my method. Learning programming might be useful. ;-)
My List named output is the List where I am gathering all broken file references.
Not wondering that I am mixing german and english language. Thats a weird attitude.
Try the Get Active Document Dependencies macro. It's short and easy to step through.
You just need an open assembly and the VB editor open. By itself, the macro isn't doing anything but spitting out filenames and paths. It just helps other processes you might want to do with that information. I don't know how comfortable you are with any of this, but if you have the basics, you should be able to see what it's doing.