Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching for Dups Macro 1

Status
Not open for further replies.

ScottWisker

Mechanical
Jan 31, 2007
15
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

 
Replies continue below

Recommended for you

I'm dealing with the same issues.

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 [li]have identical time-date creation time stamps[/li][li]are created by same installation of SW[/li]

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.
<
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.

[bat]Honesty may be the best policy, but insanity is a better defense.[bat]
-SolidWorks API VB programming help
 
Look into NoClone and DupKiller. Both are little software packages that find and allow you to delete duplicate files for directories.

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
 
Tick -
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.
 
You can't get at the SW installation info. However, the create date should be enough to tell you if the files have the same internal ID.

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?").
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor