Custom Properties linking to filename.

Discussion in 'SolidWorks' started by Todd Brake, Jul 19, 2004.

  1. Todd Brake

    Todd Brake Guest

    Hi:

    There was a thread regarding this subject back in May. I tried to reply
    to it but couldn't get it to work.

    Here is a link to the original thread:

    http://makeashorterlink.com/?S65C426D8

    I would like to try the macro feature method, but I can't seem to figure
    out how to copy/paste the code and make it work in my part files.

    Can anyone help with this?

    I'm open to a good how-to or sample part file.

    Also, could this method work for assemblies as well? Macro "feature"
    seems to indicate that it won't, but .....

    Thanks guys.

    Todd
     
    Todd Brake, Jul 19, 2004
    #1
  2. Todd Brake

    Seth Renigar Guest

    Todd,

    I gave up on this issue back on 05-06-03 when I first started that thread.
    I just played with it again and found that if you set
    $PRP:"SW-File Name"
    as the custom property value, it will actually add the filename. I don't
    think it used to do this when I asked the question back in SW03. But it
    does now (SW04 SP3.0). I also did a "Save-As" a new filename and it updated
    properly.

    Now, if I can just remember why I needed to do this way back then, this may
    be useful....
     
    Seth Renigar, Jul 21, 2004
    #2
  3. I went ahead and made an SWP for everyone...
    http://www.mikejwilson.com/solidworks/api-macros/link_filename_to_desc.zip

    Summary:

    This macro will link the custom property "Description" to the actual
    name of the file (minus the extension).

    The link will always update every time a CTR-Q is performed

    **************************************************************************

    Instructions:

    *) Start a new part or assembly or open existing

    *) Save

    *) Tools-> Macro-> Run

    *) Select macro

    **************************************************************************

    Notes:

    *) Will work in an assembly or part

    *) Document must be saved first before running macro

    *) If 'Description' IS in Custom Properties, it must be typed with an
    uppercase 'D' and lowercase for the remaining characters

    *) If 'Description' IS NOT in Custom Properties, it will be created

    *) Rebuild does not update the custom property! If you do a 'save-as'
    with new file name, rename the part in explorer etc. You must do
    a 'CTRL-Q' to see changes.

    *) Does not effect configuration specific properties

    **************************************************************************

    Maybe someone can update the macro to remove some of the limitations.

    Mike Wilson
     
    Mike J. Wilson, Jul 22, 2004
    #3
  4. Todd Brake

    Seth Renigar Guest

    The custom property solution serves the same purpose and it automatically
    updates with name changes if you do 'save-as'
    with new file name or rename the part in explorer. What would the benefits
    be of using this macro instead?
     
    Seth Renigar, Jul 23, 2004
    #4
  5. That's what I'd like to know! But since someone went to the trouble
    of writing the macro, I figured I'd save it as a file for anyone to learn
    from. It's a nice demonstration of a Macro Feature that could be
    tweaked to do something else in the future.

    Mike
     
    Mike J. Wilson, Jul 23, 2004
    #5
  6. Todd Brake

    Seth Renigar Guest

    Someone probably wrote the macro back when (like I said in my first reply)
    the custom property solution didn't work. If I remember correctly, in SW03
    when you tried to do this, it would tag on the file extension with the
    filename.
     
    Seth Renigar, Jul 23, 2004
    #6
  7. Todd Brake

    Todd Brake Guest

    Mike:

    Thanks for doing this. Maybe I misread the old thread but the idea was
    to link the filename to the NUMBER property, not the description property.

    Yeah, you could just put the "filename" property into the part number
    area of the titleblock -- provided that your part numbers are always the
    same as the filename.

    The automagic nature of this macro really comes in handiest when you use
    a PDM tool which is reading an explicit "number" property -- then you
    end up entering the data twice -- once when you name the file and once
    when you enter in the part number. Or, if you intend to move to PDM in
    the future, it would save you the hassle of entering in Part Numbers for
    a few hundred parts. Then again, you'd probably use a script to do that
    if you didn't have this macro...

    Anyway, thanks, and do you have any advice for changing the macro to put
    the filename into the "number" property?

    Todd
     
    Todd Brake, Jul 26, 2004
    #7
  8. Mike J. Wilson, Jul 27, 2004
    #8
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.