Data card file name variable doesn't update

I have a data card variable that captures the file name without the extension. I use this value in a Dispatch script.

However, if the file is renamed, the data card variable remains fixed at the original value. This seems odd to me.

Is there a way to force the file name variable to update?

SolidworksSolidworks Pdm enterprise Pdm
Answers 5
JS
JS 2012-01-09 Best Answer

Sorry, there is no out of the box way to keep a variable linked to the file name, you'll need to write code to do it.

SF
SF 2012-01-10

All you have to do is make variables in your Dispatch script that extracts the filename without extension... I have listed the ones I use - not all are required if you just want the filename without extension.

Variable             Value

D_Length           Length(%NameOfSelectedFile%)

D_DotPos          ReverseFind(%NameOfSelectedFile%,.)

D_ExtLength      Sub(%D_Length%,%D_DotPos%)

D_FileName       Left(%NameOfSelectedFile%,%D_DotPos%)

D_ExtName       Right(%NameOfSelectedFile%,%D_ExtLength%)

Message was edited by: Tim Read - just fixing a typo in the D_FileName extraction.

SF
SF 2012-01-10

Thanks Tim,

Originally I used that approach and then abandoned it because it seemed a data card variable was super simple (and it would have been if the variable updated with file name changes).

You have inspired me to give your suggestion a try . . .

PW
PW 2012-03-13

I have the file named "453561234567.sldprt" and use the variables above in a dispatch to fill in a data card value. When I run the dispatch with the D_FileName it puts 19 in the data card. I was just using the 3 variables: D_Length, D_DotPos and D_FileName. I added all variables and changed the names to match the ones above exactly and I still get the 19. I have them all entered as string values as I could not find an integer value or anything like that.

Do you have any idea why the D_FileName variable would be returning the D_Length variable value? I am using EPDM 2011.

PW
PW 2012-03-13

Ok I got it. I had to add an extra variable and use the correct one for the output.

Here is what I used for variables and I used "FileName" for the output without the extension.

Variable               Value

TotalLength         Length(%NameOfSelectedFile%)

DotPos               ReverseFind(%NameOfSelectedFile%,.)

ExtLength           Sub(%TotalLength%,%DotPos%)

NameLength        Sub(%TotalLength%,%ExtLength%)

FileName             Left(%NameOfSelectedFile%,%NameLength%)

Thanks for the starting point. I never would have figured it out.