Is there such a macro - rename part files by adding prefix.

Discussion in 'SolidWorks' started by John Layne, Mar 13, 2006.

  1. John Layne

    John Layne Guest

    Does anyone know of a Macro that will do the following either in SolidWorks
    or PDMWorks. Also willing to pay someone to write one.

    I have inherited number of files with a descriptive filename, I wish to add
    an alphanumeric prefix (that automatically increments sequentially) to all
    the part files within a given subassembly.

    e.g. With the main assembly and a specific subassembly open rename part
    files as below.

    Main Assembly
    ---Subassembly one
    ------Partfiles (add Prefix to all part files in this subassembly beginning
    with CW06-10-2001 incrementing sequentially)
    ---Subassembly two
    ------Partfiles (add Prefix to all part files in this subassembly beginning
    with CW06-10-5001 incrementing sequentially)
    etc

    John Layne
    www.solidengineering.co.nz
     
    John Layne, Mar 13, 2006
    #1
  2. John Layne

    Ben Eadie Guest

    Have a look at my blog at http://mountain-wave.blogspot.com/ and
    download this movie
    http://www.archive.org/download/Batch_Rename_in_Solidworks/BatchRename01.m4v

    It will get you part way...

    You can use wild cards to help rename such as "*" to retain the original
    name, but how to get the sequential numbering I am not sure what the
    characters to use are, anyone out there that can fill in the blank here?

    So to start, adding the "CW06-10-2001" prefix have a look at my vid and
    then use this for renaming
    CW06-10-2001-*.*

    Again I am sure there is some way to sequentially number these I just am
    not sure how.

    Ben
     
    Ben Eadie, Mar 13, 2006
    #2
  3. John Layne

    yozotrinity Guest

    I think this program can help you.
    Oscar's Renamer...Just Google it.
    Will show you a folder as text file which you can copy it in a text editor
    with find/replace feauteres, and when you are done just copy back and you
    are done...

    Oz
     
    yozotrinity, Mar 13, 2006
    #3
  4. John Layne

    John Layne Guest

    I have exceeded my bandwidth cap this month, so can't view your movie
    without waiting for it download for a couple of hours at dial-up speeds.

    Though without the ability to sequentially increment the numbers I not
    sure I would be that much better off.

    I do appreciate the reply though.


    John Layne
    www.solidengineering.co.nz
     
    John Layne, Mar 13, 2006
    #4
  5. John Layne

    John Layne Guest

    If I did this the SolidWorks assembly would no longer no know where to
    look for the files.

    Thanks for the suggestion.

    John Layne
    www.solidengineering.co.nz
     
    John Layne, Mar 13, 2006
    #5
  6. John Layne

    Mr. Who Guest

    Can you provide more information on your situation and what you need
    done? There are several important questions you need to answer.

    As you describe what you want I see a number of potential conflicts.

    1. What if an assembly contains multiple instances of the same part?
    You would need a macro smart enough to know when it reached a duplicate
    instance and to not rename it.

    Are you changing multiple top-level assemblies?
    2. If so do any of them share common parts/subassemblies? If so how do
    you resolve naming conflicts between those two?

    If you just have a few unique subassemblies containing unique parts
    then updating would be easy. You write a macro that checks to make
    certain Tools -> Options -> System Options Tab -> External References
    -> Update Component Names when documents are replaced is UNChecked.
    Then have a macro iterate through all subassemblies and parts and
    rename them according to your schema. However if you have either of
    the scenarios outlined above then it gets more complicated. For
    question 1 you could put in a check to see if the component name
    already contains your prefix. If so then ignore changing it. For
    question 2 you could probably use PDM/Works auto-update other
    referenced assemblies and also use the solution from question 1 to make
    sure you don't stomp on the naming schema.

    You can use the Component2::Name2 API to rename your documents
    according to your needs. I have some code for iterating through
    assembly components if you need it.

    Mr. Who
     
    Mr. Who, Mar 14, 2006
    #6
  7. John Layne

    John Layne Guest

    Thanks for your valuable input, someone is currently writing a Macro for me
    I'll pass along your well thought through comments.

    John Layne
    www.solidengineering.co.nz
     
    John Layne, Mar 15, 2006
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.