×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Searching for Dups Macro

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

RE: Searching for Dups Macro

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


  • 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://coolthingoftheday.blogspot.com/2005/07/dsofiledll-20.html>

    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.

    batHonesty may be the best policy, but insanity is a better defense.bat
    http://www.EsoxRepublic.com-SolidWorks API VB programming help

    RE: Searching for Dups Macro

    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

    RE: Searching for Dups Macro

    (OP)
    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.

    RE: Searching for Dups Macro

    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?").

    Red Flag This Post

    Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

    Red Flag Submitted

    Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
    The Eng-Tips staff will check this out and take appropriate action.

    Reply To This Thread

    Posting in the Eng-Tips forums is a member-only feature.

    Click Here to join Eng-Tips and talk with other members!


    Resources