Searching for Dups Macro
Searching for Dups Macro
(OP)
I'm trying to clean our server ...
I've written code that searches a given location for assembly files and returns all of the components referenced within.
I then compare filenames to our "vaulted" parts and return a list of matches. I was then using File Size to determine if the files were actually the same or just had the same name. However, the File Size of any given component seems not to be the most stable element to use as it can change slightly based on it global path. I then tried using the Last Modified Date, but this can also change when an assembly is rebuilt.
The goal was to replace the copies within the assembly files with the references back to the vault and delete the copies.
Does anyone know of a property accessable from the Document Manager API that could confirm that two components are identical?
PS
I am aware of the "compare geometry" function within the Utilities, but would rather not go that route.
Thanks,
wisker
I've written code that searches a given location for assembly files and returns all of the components referenced within.
I then compare filenames to our "vaulted" parts and return a list of matches. I was then using File Size to determine if the files were actually the same or just had the same name. However, the File Size of any given component seems not to be the most stable element to use as it can change slightly based on it global path. I then tried using the Last Modified Date, but this can also change when an assembly is rebuilt.
The goal was to replace the copies within the assembly files with the references back to the vault and delete the copies.
Does anyone know of a property accessable from the Document Manager API that could confirm that two components are identical?
PS
I am aware of the "compare geometry" function within the Utilities, but would rather not go that route.
Thanks,
wisker






RE: Searching for Dups Macro
If you want to tell if two parts are of identical geometry, the best place to check is mass properties (not availbale through SWDM, sorry). If the parts are identical, ALL the mass properties will be identical, including all the inertia values. Even the slightest difference will be detectable here.
Here's the true breakthrough information:
How to tell if parts have same internal ID
SW API has no publicly available path to find internal ID. However, there is a way to compare certain properties that will reveal if parts have same internal ID 99.999999999% certainty.
SW files have same internal ID if they
You can check the time-date creation time stamp using the DSOfile object. The creation date given by a DSO object will give you the time stamp that indicates if internal ID's are the same.
<http
DO NOT use time stamp from windows API, SW API, or MS Scripting. These are not the same. It has to be the DSO file object creation date property.
How dependable is this? As much as the inverse of the odds of two separate files of interest having been created at the exact same second by two different people.
http://www.EsoxRepublic.com-SolidWorks API VB programming help
RE: Searching for Dups Macro
I ended up using the trial version of NoClone for a task similar to yours. We had many copies of parts strewn throughout many directories that needed to be found and deleted prior to our pdm migration. The websites for the above packages will probably explain what criteria they use to define a duplicate.
-Dustin
Professional Engineer
Certified SolidWorks Professional
RE: Searching for Dups Macro
Getting closer. I'm using the DSO to get the created on date, but how are you returning the Installation information? I looked at everything DSO allowed and didn't see anything like that. In fact it wouldn't return SolidWorks as the application.
Also in testing I modifed a copied component, made a modification to it, and reran the test. The date created did not change, but there was nothing to indicate that the component had been modified - aside from the file size, which I already ruled out as a test.
Shaggy -
The duplicates are a portion of the larger problem. Those programs would in fact clean up the dups, but would also cause all of the assemblies to blow up with reference errors.
RE: Searching for Dups Macro
Having the same internal ID doesn't tell you if the files are identical. What it does tell you is if the files can be swapped as component or drawing references without causing an internal ID error. It can also tell if one file is a clone of another (i.e. "Is this file a saved copy or did someone create a new file with the same name?").